Problem:

In GNOME, there is not a way to setup a slide show to rotate backgrounds. But, this is easy to solve.

Solution:

Using some shell programming, the gconf tool, and cron you can easily create this.

Alot of the variables could be got rid of, but using them helps make the script clearer.

$RANDOM produces a random number between 1 and 32767. We have to multiply it by the number of files first, because if we divide it by 32767 BASH will round the number to 0…

Example:

Create the following script as /usr/local/bin/change_background

---------------------snip---------------------
#!/bin/bash
#bash script to change background

#directory to read (change this for your machine.
DIR=~/sshow
#extention to read
FILE_EXT="jpg"

FILES=( $(find $DIR -iname "*$FILE_EXT" ) )

FILE_INDEX=$[$RANDOM*${#FILES[*]}/32767]

#this is all on one  line
/opt/gnome/bin/gconftool-2 -s /desktop/gnome/background/picture_filename -t
string "${FILES[$FILE_INDEX]}"
--------------snip-----------------------------

Make the file executable

chmod +x /usr/local/bin/change_background

Now, run this a couple of times and check it all works. If it does, add it to *your* crontab.

To edit your crontab, run

crontab -e 

Add the following line

0-59/10 * * * * /usr/local/bin/change-background

which can be described as “when the minutes fall between 0 and 59 devisable by 10, and hours, days, month and day of the week are anything, run /usr/local/bin/change_background”.

Environment:

Assume all your pictures are in the your show directory, and you want to change pictures every 10 minutes.

(Visited 1 times, 1 visits today)

Category: Uncategorized
This entry was posted Wednesday, 30 August, 2006 at 12:00 am
You can follow any responses to this entry via RSS.

Leave a Reply

Your email address will not be published. Required fields are marked *

No comments yet