lxqt / pcmanfm-qt

File manager and desktop icon manager (Qt port of PCManFM and libfm)
https://lxqt-project.org
GNU General Public License v2.0
413 stars 113 forks source link

[Feature request] Allow pcmanfm-qt to use other wallpaper methods (dynamic wallpaper and videos) #1923

Closed Bluey26 closed 3 months ago

Bluey26 commented 3 months ago

Is your feature request related to a problem? Please describe.

I discovered that is possible to set wallpapers that change depending on the daytime, using one of the several images automatically, so it simulates day-time and night-time accordingly. This is handled by an external tool, called wallutils(https://github.com/xyproto/wallutils/) which handles it at "window manager level" using tools like swaybg (in lxqt+labwc) and feh in X11 (openbox/ xfwm4)

I tried it in my LXQt+Labwc session and it seems to work, but the wallpaper provided by swaybg is shown over the icons layer (the icons are hidden by the picture, but if you right click and drag randomly you can seem them). In the X11 session i tried it fastly but it seems that feh is unable to show the wallpaper over the pcmanfm-qt screen(it is shown below so you dont see the dynamic wallpaper until you log-out).

To try this, you need a set of pictures that have a .xml with them, which indicates the path to the corresponding pictures and times to shown it. For example, downloading this image set: https://github.com/japamax/gnome-kde-dynamic-wallpaper-mojave/ and then running the following command:

settimed mojave-timed.xml

another examples my need to tweak the .xml a bit to point to the correct images location.

There is also a way to set-up a video (like a repeted gif) as wallpaper using another tool, called mpvpaper (https://github.com/GhostNaN/mpvpaper) which seems to have the same issue in lxqt+labwc session, i think it uses the same kind of way (swaybg or its triggers) to set the wallpaper as a video.

This one is quite straightforward to test, you install the AUR (https://aur.archlinux.org/packages/mpvpaper) and then use it with something like this:

mpvpaper -o "no-audio --loop-playlist shuffle" '*' path_to_video (sound seems to work too, but its not needed for most wallpaper modes)

Describe the solution you'd like

Some kind of option to detect if swaybg or feh or similar programs are running in "wallpaper mode" (feh is also an image viewer) and use that as wallpaper, if present.

Describe eventual alternatives you've considered

I dont think there's enough time or priority to implement this right away inside LXQt so i considered just allow those programs to handle that.

Context

Explained in the Problem section.

Video sample:

https://github.com/lxqt/pcmanfm-qt/assets/143142826/48845c63-7879-4f3c-b1b6-bffda16e1bac

(Using another dynamic wallpaper, LXQt+Labwc session)

isf63 commented 3 months ago

A simple solution to this would be to add a desktop Wallpaper Mode that is simply RGBA #000000FF and have the compositor handle it. That could be a separate Wallpaper Mode or by adding alpha to the color picker used by "Fill with color".

EDIT: Layering might be an issue - you would want pcmanfm-qt --desktop to have a higher z-index than the wallpaper program.

stefonarch commented 3 months ago

I tried a transparent background window, doesn't work, adding alpha in config file get's removed if launched because not supported I think.

tsujan commented 3 months ago

I vaguely remember that a similar feature request was made years ago (perhaps not here). My answer is the same:

pcmanfm-qt is and will remain a lightweight file manager with a manageable code. Yes, many things are possible, but I'm afraid that doesn't mean we could add them to pcmanfm-qt.

tsujan commented 3 months ago

An example:

Personally, I like a fade effect when changing wallpapers in the slide-show mode. Two years ago, I implemented it, but I didn't make a PR (actually, I stopped using it too) because such codes weren't acceptable with pcmanfm-qt.

Bluey26 commented 3 months ago

Yes, i also understand that mantaining code with this feature would be a bit tedious because of all the window managers and the possible programs in each type of session (X11/Wayland) that LXQt already handles.

tsujan commented 3 months ago

i also understand that mantaining code with this feature would be a bit tedious

Yes, the code would become a mess if we didn't limit extra features. Sorry for my negative reply but, as I mentioned, I've given that reply to myself too (a trashing sound is another example).

Bluey26 commented 1 week ago

I was scripting some things and i realized that i could use the LXQt's Autostart section with a "timer" to change the pcmanfm-qt wallpaper according to time, and thus change the wallpaper dinamically (in a semi-automated way).

For this, i used some loops and the pictures found in https://github.com/japamax/gnome-kde-dynamic-wallpaper-mojave/tree/master/mojave

The script have a few limitations, like you have to specify the directory where the pictures are located and you have to "set" the times manually, because those are not read from picture names or any .xml or .json. You cannot use .gifs or special formats, but you can always process(extract) the dynamic pictures from those and use them with this(accepted formats are those allowed by pcmanfm-qt). Overall the script works so i decided to share it in here, for users which may like to use this feature.

The big advantage is that this is optional and does not interfere with pcmanfm-qt in any way, it only uses its "set wallpaper" command.

Having this in consideration, here is the code:

changewallpaper.sh


#!/usr/bin/env bash

#Folder in where the pictures of the dynamic wallpaper are located
directory="$HOME/Downloads/wallpapers/dynamic/mojave"

#We go to the folder containing the pictures and we obtain their names, saving them into an array
cd $directory
files=(*)

#Obtaining the number of pictures
nummberpic=$(ls | wc -l)

#We obtain the current time in hours(for hourly changes) or we obtain the amount of minutes(Hours get converted to minutes)
minutes=$(date '+%H 60 * %M + p' | dc)

hours=$(date '+%H')

#Timer used for minute approach

#temporizador() 
#{
#if [ "$minutes" -ge $1 ] && [ "$minutes" -lt $2 ];
#   then
#        background="${files[$3]}"
#        pcmanfm-qt --set-wallpaper="$directory/"$background""
#fi
#};

#Timer. We check where is our time value(check times function) and then we apply the corresponding wallpaper

temporizador() 
{
if [ "$hours" -ge $1 ] && [ "$hours" -lt $2 ];
    then
        background="${files[$3]}"
        pcmanfm-qt --set-wallpaper="$directory/"$background""
fi
};

times=()
#times=(0 180 360 420 480 540 600 660 720 840 900 960 1020 1080 1140 1260)
#times=(0 4 8 12 16 20) 
times=(0 3 6 7 8 9 10 11 12 14 15 16 17 18 19 21 22) #used for mojave dynamic wallpaper pictures

#for i in $times[i];
for ((i = 0; i <= nummberpic ; i++));do j=$((i+1)) && temporizador ${times[i]} ${times[j]} "$i" ;done
        #temporizador 660 720 1
        #echo ${times[i]}

This .sh could be launched using a cronjob or a watch command, but i preffered to use an autostart script. Here is the code:

dynamic-wallpaper.desktop

[Desktop Entry]
Exec=bash -c "~/.config/autostart/cambiarwall.sh && while true; do sleep 300; ~/.config/autostart/cambiarwall.sh ; done &"
Name=dynamic-wallpaper
Type=Application
Version=1.0
X-LXQt-Need-Tray=true

The script is launcher at log-in and then the timer is used. This will change the wallpaper instantly then use the timer. Without it, the wallpaper would not be updated at log-in until the sleep time.

one extra value should be added (22) to make the last if statement work. lt(less than) is used instead of le(less or equal) to avoid overlapping conditions.

The sleep time can be changed to the desired value. The script keeps working in the background and will check after 5 minutes (300 seconds) what is the "correct" wallpaper for the current time and change it.

changewallpaper.sh and dynamic-wallpaper.desktop files were added into ~/.config/autostart to make this launch in every log-in session. I have not tested it in X11 but it works in wayland. This does not depends in x11 or wayland so it should also work in x11.

More info about modules can be found in: https://lxqt-project.org/blog/2022/09/20/about-modules-in-lxqt/

tsujan commented 1 week ago

I may have missed something, but pcmanfm-qt's desktop already has slide show:

slide

tsujan commented 1 week ago

Moreover, see https://github.com/lxqt/pcmanfm-qt/commit/a066652b696c59f0e98b93b355ca940fd4f0592e and its related report https://github.com/lxqt/pcmanfm-qt/issues/1949. In short, now you could have any transparent image (see https://github.com/lxqt/pcmanfm-qt/issues/1949#issuecomment-2400099665) as the wallpaper and use any Wayland wallpaper engine behind it (i.e., the wallpaper engine should be started before pcmanfm-qt's desktop module, e.g., through the compositor).

Bluey26 commented 1 week ago

Moreover, see a066652 and its related report #1949. In short, now you could have any transparent image (see #1949 (comment)) as the wallpaper and use any Wayland wallpaper engine behind it (i.e., the wallpaper engine should be started before pcmanfm-qt's desktop module, e.g., through the compositor).

Yes, i checked the issue and cloned git master pcmanfm-qt. The transparent wallpaper seems to work in here, but the other tools(swaybg i.e.) tend to add the background image over(above) the pcmanfm-qt desktop icons. I guess this is related to the WM (labwc in my case). Hyprland maybe manages the layers differently, by what i have read in that issue,and the wallpaper image is shown below the transparent background provided by pcmanfm-qt.

I may have missed something, but pcmanfm-qt's desktop already has slide show:

Indeed, i have missed that option, but there are some cases in where this would not work. for example, after 21:00 the mojave wallpaper should keep in mojave_dynamic-2100.jpg but using an hourly slideshow interval would change the wallpaper, at 22:00 to mojave_dynamic-0000.jpg (which should be seen at 00:00).

tsujan commented 1 week ago

... but the other tools(swaybg i.e.) tend to add the background image over(above) the pcmanfm-qt desktop icons.

Did you try to start it before pcmanfm-qt, by adding its command to labwc's autostart config file (don't forget the ending &)?

Bluey26 commented 1 week ago

... but the other tools(swaybg i.e.) tend to add the background image over(above) the pcmanfm-qt desktop icons.

Did you try to start it before pcmanfm-qt, by adding its command to labwc's autostart config file (don't forget the ending &)?

I was reading again the comments in here, and i was suspecting that, by the "z-index" mentioned in the first comment.

Setting the wallpaper to transparent into pcmanfm-qt , then stopping pcmanfm-qt and launching settimed mojave-timed.xml and then restarting the pcmanfm-qt module seems to solve it!

tsujan commented 1 week ago

BTW, I remembered that I tested https://github.com/lxqt/pcmanfm-qt/commit/a066652b696c59f0e98b93b355ca940fd4f0592e by using swaybg inside labwc ;)

Bluey26 commented 1 week ago

BTW, I remembered that I tested a066652 by using swaybg inside labwc ;)

Awesome, what i needed to do to make it work was creating the wallpaper autostart module with the following line:

Exec=bash -c "settimed mojave-timed.xml &"
X-LXQt-Need-Tray=false

X-LXQt-Need-Tray=false seems to be important, because without this line, swaybg wil be shown over the desktop icons.

lxqt-desktop.desktop module did not need any changes, only needs setting the wallpaper to be the transparent image shared in the issue you mentioned,and the line X-LXQt-Need-Tray=true seems to be needed to make the wallpaper work properly.

Thanks a lot for this, its a really cool feature i wanted to have 😄

PS:this is solved now, no need to use the hacky bash script. PS2: settimed is used to set the timed wallpapers, it belongs to the package wallutils

PS3: i think i should have tested it further. Since wallutils loads swaybg after X time, when the transition happens, swaybg will overlay(hide) the icons again. This is because how wallutils work, so this may not be suitable for dynamic wallpapers, but it works for single swaybg or other wallpaper engine that does not kill/restart itself after the change.

tsujan commented 1 week ago

I added a general info to the Wiki.