What I want:
I am trying to write a systemd service/timer that changes wallpaper every hour. But it should also set the wallpaper on the login.
System Info:
WM: OpenBox
DM: LightDM
Wallpaper App: Nitrogen
What I tried:
# rand-wall.service
[Unit]
Description=Sets the desktop wallpaper in random
[Service]
Type=oneshot
ExecStart=/usr/bin/nitrogen --set-zoom-fill --random '/path/to/wallpapers/'
While the wallpaper is changing hourly, I cannot figure out how to make it run every time I login (when I logout and then login). So until 1 hour passes the desktop background stays “grey”.
Also, how can I change the wallpaper of the login screen?
@chromian
If I understand your question correctly, you could use additional setting
[Timer]
Persistent=true
# ...
EDIT: just noticed that this might not be what you wanted.
Anyway, try these commands:
man systemd.timer
man systemd.time
EDIT2: another way to run stuff at login is to write an autostart file into folder /etc/xdg/autostart. They are traditional .desktop files that run at login. I think @pebcak already was going this way.
Thank you pebcak and manuel for your guidance. I suspected as much that I am gonna need the autostart file of openbox. That is how EndeavourOS/Openbox “restores” the wallpaper when the user logs in. It’s just that I wanted all the “config” for the wallpaper setup to be at one place but anyway this is what I ended up doing:
The rand-wall service and timer files are as they are in ~/.config/systemd/user. I enable the timer with systemctl --user enable --now rand-wall.timer. It will take care of changing the wallpaper every hour.
Now for setting the wallpaper every time I log in, I go to ~/.config/openbox/ and edit the autostart file as: