Randomized Backdrops

#!/usr/bin/perl -w

# This little program sets my background image
# randomly in blackbox (and now openbox).
# It's called when I startx.

$backdrop_directory = "/home/willyyam/crap/backdrop/";
# Set this to your backdrop files directory.

opendir(BD, "$backdrop_directory") or die;
# Normally we'd report errors, but since we will be
# running this via script and discarding the STDOUT
# that it generates, that would be a waste of time.

@backdrops = readdir(BD);
# Grab the contents of the backdrop directory.

@spordkcab = reverse(@backdrops);
pop(@spordkcab);
pop(@spordkcab);
# The first two entries readdir() finds are
# . and  ..  We don't want to hand these
# entries to bsetbg, so I reverse the array
# and do away with them.  There is a smooth,
# tidy way to do this.  I don't care :-)

$pic_o_the_moment = $spordkcab[ rand @spordkcab];
$pic_o_the_moment = $backdrop_directory . $pic_o_the_moment;
`/home/willyyam/bin/bsetbg $pic_o_the_moment &`;

# This the program call to bbsetbg, written by
# tmk@lordzork.com, is what does all the work --
# I just call it.

exit;

# William O'Higgins yam@nerd.cx