#Select all the JPG and PNG images from the folder. iname is used to ignore the case. IMAGES=`find . -iname '*.jpg' -o -iname '*.png'`

#Counts the number of files found in the previous step N=`echo $IMAGES | wc -w`

#Picks out a random number using the system variable RANDOM ((N=RANDOM%N))

#Picks out that specific file. #The files are returned as ./file1 ./file2 etc. #So the first cut command uses / as delimiter and hence the field name specifies the file name #The second cut command is use to extract the specific file name BACKGNAME=`echo $IMAGES | cut -d '/' -f $N | cut -d ' ' -f 1`

#The gconftool-2 is the gnome window managing program. --set and --get variables are used to pass values to this to various parameters #The /desktop/gnome/background/picture_filename variable has the filename of the current background and so we replace it with the new one gconftool-2 -t str --set /desktop/gnome/background/picture_filename "/home/harish/Pictures/Random/$BACKGNAME"

#Done! Now put this file in ~/.gnome2/naultilus-scripts #You can even crontab it for auto wallpaper changing