danyspin97 / wpaperd

Modern wallpaper daemon for Wayland
GNU General Public License v3.0
312 stars 24 forks source link

wpaperd does not update via systemd timer -> systemd service -> bash script #47

Closed fhteagle closed 5 months ago

fhteagle commented 11 months ago

Recent convert to hyprland, trying to duplicate the setup I have had on gnome, plasma, and other desktops for quite some time. I have a script that runs xplanet periodically, updating a map of the world with day/night regions, clouds, and seasonally realistic snow cover.

If I fire this script from a command line in a terminal within hyprland, everything works as expected and wpaperd loads and displays the new image as I expect. If I fire the same script from a systemd user service, wpaperd does NOT update the wallpaper image. systemd does have the correct $DISPLAY variable, but I am not sure what else wpaperd needs to work from a systemd --user context.

Any ideas?

Thanks

danyspin97 commented 11 months ago

Hello @fhteagle, I think that DISPLAY and WAYLAND_DISPLAY should be enough to make it work. Can you please try with both environment variables?

fhteagle commented 11 months ago

Script reported these variables were in use when systemd triggered the script:

Oct 30 09:11:17 _myhost_ earthnowwpaperd.sh[11789]: Display is :1
Oct 30 09:11:17 _myhost_ earthnowwpaperd.sh[11789]: Wayland Display is wayland-1
Oct 30 09:11:17 _myhost_ earthnowwpaperd.sh[11789]: Setting the wallpaper now via wpaperd...

After that last echo line, my script simply runs wpaperd (with no arguments) and then exits. When I run my script from an alacritty terminal, I get the correct env variables reported and the hyprland wallpaper is correctly updated. Same if I log in on a different system tty and manually set $DISPLAY and $WAYLAND_DISPLAY first. But from systemd timer, the env variables are reported correctly but no wallpaper update occurs.

Let me know if you have any other troubleshooting ideas. Thanks.

danyspin97 commented 11 months ago

Probably unrelated, are you using wpaperd -n? I am thinking that maybe systemd kills every child when the script exits, but I am not sure.

fhteagle commented 11 months ago

Good suggestion, as I did try with -n just now ... which does result in systemd service firing the script and updating the wallpaper once, but only once. The script does not exit after wpaperd -n, though, and on the next triggering of the timer/service unit nothing happens.

danyspin97 commented 11 months ago

Okay, so now I got a better understanding. Wpaperd doesn't need a timer, you can set the time in the config file ~/.config/wpaperd/wallpaper.toml:

[default]
duration = "30m"

Just having a systemd service (and not a timer) wpaperd will change the wallpaper every 30 minutes or any time you choose. If you still want to use a systemd timer, you can call the command wpaperctl next-wallpaper once the wpaperd daemon is running. So in this case you need a service and a timer.

fhteagle commented 11 months ago

Okay I will play around with that idea instead. The package from Arch AUR did not provide wpaperctl, so I just built it from source manually per your Readme instructions. Definitely more to explore later today.

Does the "duration" config option cause wpaperd to reload a single file when path is set to that though, or does duration only cycle through multiple files in a directory path?

Any way to force wpaperd/wpaperctl to load the newest entry in a directory after each duration is reached?

danyspin97 commented 11 months ago

Does the "duration" config option cause wpaperd to reload a single file when path is set to that though, or does duration only cycle through multiple files in a directory path?

The latter, it only works when path is set to a directory.

Any way to force wpaperd/wpaperctl to load the newest entry in a directory after each duration is reached?

wpaperd always reload the list of files when drawing a new wallpaper. Is this what you meant?

fhteagle commented 11 months ago

Finally got a chance to test things out. Looks like wpaperctl next-wallpaper is triggering the single file re-load like I was looking for. Thanks for the help and support.

I'll mod the PKGBUILD scripts to match your README instructions and post them to the AUR listing for wpaperd and wpaperd-git, so that we'll get wpaperctl by installing from the AUR too. No idea if the official maintainer will actually update the official PKGBUILD, but at least there will be another option out there.....

fhteagle commented 5 months ago

Sorry to have to reopen this, but I migrated to a new SSD, full reinstall of arch, and now /home/myuser/.cargo/bin/wpaperctl next-wallpaper is not reloading the newly overwritten image file again. Using cargo install 'd from git. Made sure the active wpaperd instance is the git compiled version in .cargo/bin . My config .toml only has one wallpaper path entry in it:

path = "/home/myuser/.xplanet/earthnow/earthnow_m.jpg"

Not sure what changed between my last install and this one. If you have any good ideas, please let me know. Thanks.

danyspin97 commented 5 months ago

Hello @fhteagle.

Not sure what changed between my last install and this one. If you have any good ideas, please let me know. Thanks.

The codebase has been changed a lot, that might have been the issue. next-wallpaper is not made to issue a reload of the current file, so that might have stopped working...I might add a new reload-wallpaper command so that it does exactly that. I'll keep you posted.

fhteagle commented 5 months ago

Thanks for the reply. Yes a reload-wallpaper command would be perfect. No rush though, I just found swww which looks like it will work for me as well.

fhteagle commented 5 months ago

Just took a few minutes to test this. It does seem to be working as expected, after I actually got the newest binaries built and loaded. New instructions using rinstall are not working, but I filed a bug over on that project instead. Thanks for the feature add.