CahBojonegoro

Rawe Rawe Rantas, Malang Malang Putung

Random Wallpaper Changer Shell Script

leave a comment »

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 ..

Advertisements

Written by cahbojonegoro

December 11, 2008 at 2:54 pm

Posted in Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: