random wallpaper script
Something that I had been meaning to do for quite some time was to write a script that sets a random wallpaper from a specific directory. My window manager is fluxbox and the wallpaper setter is feh. This quite simply sets the wallpaper to a random image residing in ~/wallpapers every 30 minutes.
Changing the sleeptime variable will quite obviously change the duration between wallpaper changes. I had thought of using something like ‘at’ to schedule the wallpaper updates however if I’m not in the mood for the wallpaper that it had just set I could do a quick ‘killall sleep’ to change it again. This, however, has its problems when there are other sleep processes running, but on my particular workstation this is not an issue.
#/bin/bash
# Random wallpaper
# add to ~/.fluxbox/startup as:
# $HOME/bin/random-wallpaper.sh &
#
# $Id: random-wallpaper.sh 27 2006-12-16 12:39:28Z anton $
#
sleeptime="30m"
wallpapers="${HOME}/wallpapers"
export wpsetters=feh
while true
do
sleep ${sleeptime}
/usr/bin/fbsetbg -r "${wallpapers}"
done
Of course as you can see from the comments, you can run it from ~.fluxbox/startup, and mine is as follows:
$ egrep -v "^#|^$" ~/.fluxbox/startup
export LC_ALL=C
GSDPID=`pidof gnome-settings-daemon`
if [ "x$GSDPID" == "x" ]; then
/usr/bin/gnome-settings-daemon &
/usr/bin/gnome-volume-manager &
fi
/usr/bin/wmGrabImage -u http://mirror.bom.gov.au/radar/IDR033.gif &
/usr/bin/conky &
/usr/bin/gaim &
/usr/bin/xscreensaver -nosplash &
${HOME}/bin/random-wallpaper.sh &
${HOME}/bin/sysinfo-g15lcd.sh &
exec /usr/bin/fluxbox
Filed under: m.o