Freebsd9.2 profoak randomWallpaper

From wikinotes

~/.xmonad/Extensions/randomWallpaper

Setup:

chmod 755 ~/.xmonad/Extensions/randomWallpaper
ln -s ~/.xmonad/Extensions/randomWallpaper /usr/bin/randomWallpaper

Depends:

sudo pkg_add -r feh


#!/bin/sh
# Random Wallpaper chooser
# I wrote this script because I am lazy, and I didn\'t feel like constantly changing the feh command
# in .xmonad/xmonad.hs

# It checks for all of the files of the below listed types, counts them, generates a random number
# between 1 and that number, and assigns that wallpaper to the desktop.
# NOTE** this is specific to freeBSD


    # Counts number of files containing an extension in ~/.../Wallpapers/ with the extensions listed.
num=$(ls /home/will/wallpapers | grep -e .jpg -e .jpeg -e .png -e .tga -e .gif --include=PATTERN | wc -l)

    # write all image paths to a tmpfile called imglist.
ls /home/will/wallpapers | grep -e .jpg -e .jpeg -e .png -e .tga -e .gif --include=PATTERN | sed \'s_*__\'  \x3E imgList



    # find a random number between 1 and the number of images
#num=$(echo "$num + 1" | bc -l)
randomNum=$(jot -r 1 1 $num)



a=0

for line in $(cat imgList) ; do 
    a=$(expr $a + 1)
    if [ "$a" == "$randomNum" ] ; then
        imagePath=/home/will/wallpapers/$line
    fi
done


feh --bg-scale $imagePath
rm imgList