llebegue
May 31st, 2006, 07:31 AM
I couldn't make up my mind about what would be my wallpaper ...
So I wrote a small script to choose randomly from my collection.
Pre-requesites are :
- using Linux or another Unix flavor (well Ubuntu here ...)
- using Gnome 2
- Using the standard desktop configurator (gnome-background-properties) as a reference file.
What the script does :
1- look the Gnome background configuration file
2- pick-up a random image from gnome-configuration-properties (excluding images that are not in my home directory 'grep $HOME' but this is my personal choice)
3- tell Gnome to change the background
4- wait for 5 minutes and change the background randomly again
----------------------------------------------------------------------------
#!/bin/bash
while [ 1 == 1 ]
do
ALIST=( `grep filename ~/.gnome2/backgrounds.xml | sed 's/<filename>//g' | sed 's/<\/filename>//g' | grep $HOME` )
RANGE=${#ALIST[@]}
let "number = $RANDOM % $RANGE"
gconftool-2 -t string -s /desktop/gnome/background/picture_filename ${ALIST[$number]}
sleep 300
done
----------------------------------------------------------------------------
Save this file with a relevant name (background.sh for instance) with execution rights (chmod u+x background.sh)
I wrote it on Ubuntu Dapper Beta ... but should work on previous version with Gnome 2
How to run it :
- open a terminal and run '/xxx/xx/xx/background.sh &' ... & is important to detach this process from the terminal one
- exit the terminal
or
- System -> Preferences -> Sessions
- Startup Program Tab => Add
- Type the command line like above and validate
- The next time you open a session the background will be chosen randomly
et voilą !
Tested on Ubuntu 6.06 ... works perfectly
PS thanks to poptones for the original script on this thread (http://www.ubuntuforums.org/showthread.php?t=49336)
So I wrote a small script to choose randomly from my collection.
Pre-requesites are :
- using Linux or another Unix flavor (well Ubuntu here ...)
- using Gnome 2
- Using the standard desktop configurator (gnome-background-properties) as a reference file.
What the script does :
1- look the Gnome background configuration file
2- pick-up a random image from gnome-configuration-properties (excluding images that are not in my home directory 'grep $HOME' but this is my personal choice)
3- tell Gnome to change the background
4- wait for 5 minutes and change the background randomly again
----------------------------------------------------------------------------
#!/bin/bash
while [ 1 == 1 ]
do
ALIST=( `grep filename ~/.gnome2/backgrounds.xml | sed 's/<filename>//g' | sed 's/<\/filename>//g' | grep $HOME` )
RANGE=${#ALIST[@]}
let "number = $RANDOM % $RANGE"
gconftool-2 -t string -s /desktop/gnome/background/picture_filename ${ALIST[$number]}
sleep 300
done
----------------------------------------------------------------------------
Save this file with a relevant name (background.sh for instance) with execution rights (chmod u+x background.sh)
I wrote it on Ubuntu Dapper Beta ... but should work on previous version with Gnome 2
How to run it :
- open a terminal and run '/xxx/xx/xx/background.sh &' ... & is important to detach this process from the terminal one
- exit the terminal
or
- System -> Preferences -> Sessions
- Startup Program Tab => Add
- Type the command line like above and validate
- The next time you open a session the background will be chosen randomly
et voilą !
Tested on Ubuntu 6.06 ... works perfectly
PS thanks to poptones for the original script on this thread (http://www.ubuntuforums.org/showthread.php?t=49336)