To change the wallpaper randomly, there are a few things on the to-do list:
First of all, we need to select a random wallpaper from a directory. The
following command should do that, using the
wallpaper=` for f in /opt/wallpapers/*; do echo $RANDOM:$f; done | sort -n | head -n 1 | cut -d: -f2- `
Now, to let Gnome know about the new wallpaper:
gconftool-2 -s /desktop/gnome/background/picture_filename -t string "$wallpaper"
Wrap the two commands in a script and place the script in
#!/bin/bash dir=/opt/wallpapers gconftool-2 -s /desktop/gnome/background/picture_filename -t string "` for f in $dir/*; do echo $RANDOM:$f; done | sort -n | head -n 1 | cut -d: -f2- `"
Make the script executable:
chmod +x $HOME/change-wallpaper.sh
Finally, add the following line to
/etc/crontab, replacing both
instances with your actual username:
7 * * * * username env `dbus-launch` sh -c 'trap "kill $DBUS_SESSION_BUS_PID" EXIT; /home/username/change-wallpaper.sh'
This will run the wallpaper changing script every hour at the 7th minute.