Use Systemd Timer to change Gnome wallpaper

Intro

In my gnome desktop, I have a script that run at login to random a new wallpaper. I still want to change wallpaper every 30 minutes. So systemd timer is created to do the job.

Use a systemd timer

  1. create directory at ~/.config/systemd/user

  2. create wallpaper.service

wallpaper.service
[Unit]
Description=Random Wallpaper Script

[Service]
ExecStart=/path/to/script/random_wallpaper_gnome_v2.sh

when task is running, the random_wallpaper_gnome_v2.sh will be executed.

  1. create wallpaper.timer
wallpaper.timer
[Unit]
Description=Run wallpaper task every 30 minutes after start

[Timer]
OnActiveSec=30min
OnUnitActiveSec=30min

[Install]
WantedBy=timers.target

OnActiveSec will activate the task 30 minutes after timer is started.
OnUnitActiveSec will activate again in 30 minutes after task is finished.

  1. Enable and start timer.
SH
systemctl --user daemon-reload
systemctl --user enable wallpaper.timer
systemctl --user start wallpaper.timer

License

Author: Vorasilp K.

Link: https://vorasilp.com/posts/wallpaper-timer/

License: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.