Skip to content

Instantly share code, notes, and snippets.

@ravishi
Last active August 29, 2015 14:11
Show Gist options
  • Save ravishi/f40aa653ad46a36d0edc to your computer and use it in GitHub Desktop.
Save ravishi/f40aa653ad46a36d0edc to your computer and use it in GitHub Desktop.
Call this often to get a new wallpaper every day.
#!/bin/bash
#
# random-wallpaper.sh
# Call this often enough to get a new wallpaper every day.
# Where the wallpapers are located
WALLPAPERS=~/pictures/wallpapers/r-wallpapers
# Where the last change date will be saved
REGISTRY=~/.random-wallpaper
# The date format
DATEFORMAT=%Y-%m-%d
# The actual command
if [[ "`cat $REGISTRY 2> /dev/null`" != "`date +$DATEFORMAT`" ]]; then
wallpaper="`find $WALLPAPERS | grep -E '(\.png|\.jpe?g)' | shuf -n 1`"
gsettings set org.gnome.desktop.background picture-uri "file://$wallpaper" && date +$DATEFORMAT > $REGISTRY
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment