Good work by Harish..
---------- Forwarded message ----------
From: Harish R <harishindian@gmail.com>
Date: Sun, Apr 18, 2010 at 3:17 AM
Subject: Random Wallpaper Changer Script
To: narendra.sisodiya@gmail.com
Hello sir,
Sorry for the delay but here is the code. #!/bin/sh #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
((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
From: Harish R <harishindian@gmail.com>
Date: Sun, Apr 18, 2010 at 3:17 AM
Subject: Random Wallpaper Changer Script
To: narendra.sisodiya@gmail.com
Hello sir,
Sorry for the delay but here is the code. #!/bin/sh #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
((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
No comments:
Post a Comment