summaryrefslogtreecommitdiff
path: root/random_wallpaper.sh
blob: df0624ac28731a2ca0988b048badfffd2c26b2b7 (plain)
    1 #!/usr/bin/env bash
    2 #
    3 # Recursively searches the specified directory (the first script argument),
    4 # randomly selects one image, and set that image as the wallpaper.
    5 #
    6 # Usage:
    7 #   random_wallpaper.sh /path/to/wallpapers
    8 #
    9 # Requirements:
   10 #   feh
   11 #
   12 
   13 # Check for feh
   14 which feh 2>/dev/null 1>/dev/null
   15 if [[ $? == 1 ]]; then
   16   echo "Required program 'feh' not found. Please install and run again."
   17   exit 1
   18 fi
   19 
   20 # Make sure a wallpaper path was specified
   21 if [[ -z $1 ]]; then
   22   echo "Please specify a wallpaper path."
   23   exit 1
   24 fi
   25 
   26 # This needs to be set if scheduling in crontab since crontab don't have
   27 # displays
   28 # export DISPLAY=:0
   29 
   30 search_path=$1
   31 
   32 # Randomly select a wallpaper to set
   33 picture=$(find ${search_path} -type f -name '*.jpg' -o -name '*.png' | sort -R | head -n 1)
   34 
   35 # Set the wallpaper
   36 feh --bg-fill "${picture}"

Generated by cgit