Skip to content

Instantly share code, notes, and snippets.

@cnicodeme
Created July 3, 2023 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnicodeme/899cef6d2f2436a6e4eba45dd7437622 to your computer and use it in GitHub Desktop.
Save cnicodeme/899cef6d2f2436a6e4eba45dd7437622 to your computer and use it in GitHub Desktop.
I script that would run hourly to change the background wallpaper on Linux for images coming from Unsplash. They disabled source.unsplash.com so it doesn't work anymore.
#!/bin/bash
# They stopped "source.unsplash.com" service
# So that script doesn't work anymore unfortunately ...
# If started as root, then re-start as user "gavenkoa":
if [ "$(id -u)" -eq 0 ]; then
exec sudo -H -u YOUR_USERNAME $0 "$@"
fi
REAL_UID=$(id --real --user)
PID=$(pgrep --euid $REAL_UID gnome-session | head -n 1)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2- | sed -e "s/\x0//g")
wget -q -O /tmp/wallpaper.jpg https://source.unsplash.com/1920x1080/?landscape,mountain,forest,stars,space,galaxy;
gsettings set org.gnome.desktop.background picture-uri-dark file:///tmp/wallpaper.jpg;
gsettings set org.gnome.desktop.background picture-uri file:///tmp/wallpaper.jpg;
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment