18 April 2010

Random Wallpaper Changer Script

Good work by Harish..

---------- Forwarded message ----------
From: Harish R <>
Date: Sun, Apr 18, 2010 at 3:17 AM
Subject: Random Wallpaper Changer Script

Hello sir,
Sorry for the delay but here is the code.


#Specify the directory containing the wallpapers
cd /home/harish/Pictures/Random

#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

#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
gconftool-2 -t str --set /desktop/gnome/background/picture_filename

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

Posted via email from LUG@IITD Community Blog

Post a Comment