Created
July 3, 2023 14:45
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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