Last active
June 2, 2016 04:42
-
-
Save OrangeCrush/55f0c2099a3ec956871c to your computer and use it in GitHub Desktop.
This file contains 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 | |
# | |
# Randomly change wallpaper. | |
# | |
# Pass the directory to serve files from as the first arg | |
# | |
PICDIR=$1 | |
[[ -d $PICDIR ]] || exit 1 | |
# | |
# Allow the script to be run from cron | |
# | |
D_PID=$(pgrep gnome-session) | |
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$D_PID/environ|cut -d= -f2-) | |
NUMPICS=$(find $PICDIR -type f | wc -l) | |
VAL=$((RANDOM % ($NUMPICS) + 1)) | |
PICFILE=$(find $PICDIR -type f | sed -n ${VAL}p) | |
gsettings set org.gnome.desktop.background picture-uri file://$PICFILE | |
echo "[$(date)] Changed wallpaper to $PICFILE using file $PICFILE generated from random no $VAL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment