Article
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.
Disclaimer: As with everything else at Cool Solutions, this content is definitely not supported by Novell (so don't even think of calling Support if you try something and it blows up).
It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.
Related Articles
User Comments
- Be the first to comment! To leave a comment you need to Login or Register
- 4269 reads


0