Setup a service to rotate random wallpaper on Linux with Systemd.
Requires feh (imager viewer) to do the work.

1. Create shell script to set desktop background

 #! /bin/bash
 #
 # edit BGPATH to reflect a path to your folder
 # with backgrounds
 BGPATH="/path/to/backgrounds"
 bg=$(find $BGPATH -type f -name "*.jpg" | shuf -n1)
 feh --bg-scale "file://$bg"

Save it as rotatebg.sh script in ~/.config directory.

2. Create Systemd timer

[Unit]
Description=Rotate wallpaper timer

[Timer]
OnCalendar=*:0/10

This will change background every 10 minutes. For some other timeing change value accroding to format *:0/minutes. For more info see manual.

Save it as wallpaper.timer in ~/.config/systemd/user directory.

3) Create Systemd service

[Unit]
Description=Rotate wallpaper

[Service]
Type=oneshot
ExecStart=/home/user/.config/rotatebg.sh
#exchange 'user' for your username in above line

Save it as wallpaper.service in ~/.config/systemd/user directory.

5) Enable service

 systemctl --user enable wallpaper.timer

6) Start service

 systemctl --user start wallpaper.timer
Report abuse