How to run systemd service every hour but also everytime user logs in?

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 

Description=Sets the desktop wallpaper in random

ExecStart=/usr/bin/nitrogen --set-zoom-fill --random '/path/to/wallpapers/'

# rand-wall.timer

Description=Sets the desktop background randomly - timer




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?

nitrogen has own settings, It can change wallpaper all on its own at startup,
if set up that way.

I know another distro that uses this option, I uninstall it as I hate change.



1 Like

There is also variety a wallpaper changer, it is in the repos (or aur can’t remember :smiley: ).

1 Like

In community repo.

1 Like

At work :smiley: Lovely Windows 10, it is PITA pleasure to use :rofl:

1 Like

Though there might be a way to get it done the way you want with services and timers, you could execute that command line at openbox startup:

and then let the timer to take care of running it at hourly basis.

1 Like

For just in case…

1 Like

If I understand your question correctly, you could use additional setting

# ...

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. :wink:


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:

# Wallpaper
# nitrogen --restore &
nitrogen --set-zoom-fill --random '/path/to/wallpapers/' &


  1. A random wallpaper is set every time I log in.
  2. A random wallpaper is set every 1 hour.

I am actually a long time user of variety and I love it. I am looking for something light… that is all.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.