Saturday, February 21, 2009

Openbox Automatic Wallpaper Script

For Openbox, I found a script to use to set things up so that a new (and randomly chosen) wallpaper (background) will appear each time I log in. I use the Linux image viewer feh to handle the wallpapers, etc.

Below, the autostart script (autostart.sh) and the wallpaper script (wallpaper.sh) I'm using in Openbox:

~/.config/openbox/autostart.sh

# Run the system-wide support stuff
. $GLOBALAUTOSTART

# Programs to launch at startup
#numlock
numlockx &

#screensaver
xscreensaver &

# Programs that will run after Openbox has started
(sleep 2 && pypanel) &

#My wallpaper (random wallpaper script)
./wallpaper.sh


The last line in the autostart.sh script calls the following script:

~/wallpaper.sh

#!/bin/bash

WALLPAPERS="$HOME/photos-openbox"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[*]}
SHOW=$(( $RANDOM % $RANGE ))

feh --bg-scale $WALLPAPERS/${ALIST[$SHOW]}


I created the file ~/photos-openbox to contain the photos used in the wallpaper.sh script.

No comments: