Skip to content

Instantly share code, notes, and snippets.

@shouya
Last active December 29, 2015 14:39
Show Gist options
  • Save shouya/7685273 to your computer and use it in GitHub Desktop.
Save shouya/7685273 to your computer and use it in GitHub Desktop.
Automatically change wallpaper randomly every X minutes.
#!/bin/bash
export HOME=/home/shou
export BG_DIR="$HOME/Pictures/Anime/wallpapers"
export DISPLAY=':0'
rand_bg() {
find "$BG_DIR" -iname "*.jpg" -o -iname "*.png" | shuf | head -n1
}
set_bg() {
read bg_file
feh --bg-fill "$bg_file"
echo "$bg_file"
}
if [ -t 0 -o "$1" = "startup" ]; then
rand_bg | set_bg
else
set_bg
fi
*/20 * * * * root test -x /home/shou/scripts/auto_set_bg.sh && /home/shou/scripts/auto_set_bg.sh startup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment