Tuesday, January 8, 2013

another random wallpaper changer

I found another random wallpaper changing script in this blog entry: "Slick random wallpaper changer nitrogen openbox debian"

That blog is called linux mint debian, and looks like it contains some nice stuff.

I needed something that would give me random wallpapers in Openbox in openSUSE 12.2. I didn't have Nitrogen or feh installed, but had installed xli instead.

First, I created the directory ~/wallpapers-openbox and filled it with images that would fit my screen correctly.

Then I created my own version of the author's script and made it executable. Here's my script, /home/steve/wallpaper-script1:

#! /bin/bash
WALLPAPERS="/home/steve/wallpapers-openbox"
ALIST=( `ls -w1 $WALLPAPERS` )
RANGE=${#ALIST[@]}
let "number = $RANDOM"
let LASTNUM="`cat $WALLPAPERS/.last` + $number"
let "number = $LASTNUM % $RANGE"
echo $number > $WALLPAPERS/.last
xli -onroot -fullscreen $WALLPAPERS/${ALIST[$number]}

I tested this from the terminal and it worked fine, so I added it to my Openbox menu by editing ~/.config/openbox/menu.xml:



I can click on that menu entry whenever I want to change to some random wallpaper from my wallpapers-openbox directory.

To make the script autostart when I log into Openbox, I added the following line to ~/.config/openbox/autostart:

wallpaper-script1 &

No comments: