Skip to content

Instantly share code, notes, and snippets.

@dbanetto
Created August 15, 2023 01:36
Show Gist options
  • Save dbanetto/eccf7bd2d71c155026fa7cba28c49c72 to your computer and use it in GitHub Desktop.
Save dbanetto/eccf7bd2d71c155026fa7cba28c49c72 to your computer and use it in GitHub Desktop.
GNOME 44 Auto-rotate desktop background

Automaticly rotating wallpapers in Gnome 44

This method uses a

  • shell script to update the relvant gsettings
  • Systemd service to run the script
  • Systemd timer to periodically run the script

Installation

1. Copy & update scipt

Copy change-wallpaper.sh & update the WALLPAPERS variable to point to your wallpapers.

Ensure that the script is executable by running chmod +x change-wallpaper.sh

2. Copy systemd units

Copy change-wallpaper.service and change-wallpaper.timer to ~/.config/systemd/user.

Ensure that the ExecStart in ~/.config/systemd/user/change-wallpaper.service points to change-wallpaper.sh

Try it out with systemctl --user start change-wallpaper

3. Enable them

Enable the systemd units with:

systemctl --user enable change-wallpaper.timer
[Unit]
Description=Change desktop wallpaper
[Service]
Type=oneshot
ExecStart=/bin/sh /home/dbanetto/.local/bin/change-wallpaper.sh
[Install]
WantedBy=default.target
#!/bin/sh
set -e -o pipefail
# Update to point to your location of wallpapers
WALLPAPERS=/home/dbanetto/Pictures/Wallpapers
SELECTION=$(find "${WALLPAPERS}" -type f -name "*.jpg" -o -name "*.png" | shuf -n1)
gsettings set org.gnome.desktop.background picture-uri "file://$SELECTION"
# Sets the -dark variant to be the same to ensure the user sees the change
gsettings set org.gnome.desktop.background picture-uri-dark "file://$SELECTION"
[Unit]
Description=Run change-wallapper periodically
[Timer]
OnBootSec=1min
OnUnitActiveSec=3h
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment