Archive for December 11th, 2008
Random Wallpaper Changer Shell Script
Boring with the same wallpaper all day long in your gnome desktop. This simple script will change your gnome desktop wallpaper randomly. Originally taken from here , modified to allow using wallpaper filename that contain spaces and give text output for the randomly choosen wallpaper.
open a text editor, copy and paste this code.
( change the WALLPAPER_DIR to your Wallpaper directory )
#!/bin/sh
## Gnome Random Wallpaper Changer Script
## Originally by http://atutility.com/2008/11/26/change-background-wallpaper-randomly-on-ubuntu-810-intrepid-ibex/
## Modified to fix error when there is a space in wallpaper filename & Add text output ( for conky ) by heri.cahyono{at}gmail.com# Wallpaper directory – Change to suit your wallpaper location
WALLPAPER_DIR=/media/sda5/Appearance/Wallpaper/RandomWallpaper# Choose one file randomly
choosenWall=`find $WALLPAPER_DIR -name \*.jpg | sort -R | tail -n 1 | sed “s/ /\\\ /g”`# File name of selected wallpaper
wallName=`echo $choosenWall | cut -d ‘/’ -f 7`
echo “Current Wallpaper is $wallName”# Change the wallpaper
/usr/bin/gconftool-2 -t str -s /desktop/gnome/background/picture_filename “$choosenWall”
Save as chgwall.sh then make it executable.
chmod +x chgwall.sh
That’s it, open terminal and execute the file. You should get your gnome desktop wallpaper changed.
Now, there are some alternative if you want to run this automatically.
1. Create a cronjob to execute the script. let say every one hour.
2. Add to gnome session startupĀ ( System -> Preferences -> Sessions ). Then add the script on the startup programs. You will get your wallpaper changed every time you login.
3. Add to conky config file using execi to change the wallpaper at specified interval.
${color lightgrey} ${execi 3600 /media/sda5/Appearance/chgwall.sh}
Have a nice wallpaper ..







