#!/usr/bin/perl -w # This little program sets my background image # randomly in blackbox (and now openbox). # It's called when I startx. $isxrunning = `ps -C startx | grep "startx"`; if ($isxrunning =~ "startx") { changebackdrop(); } else { exit; } sub changebackdrop { if (!defined $ARGV[0]) { $backdrop_directory = "/home/willyyam/misc/bmps/"; # 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 :-) $randpic = $spordkcab[ rand @spordkcab]; $randpic = $backdrop_directory . $randpic; `/usr/bin/Esetroot -display :0.0 $randpic`; #`/usr/bin/X11/xli -display :0.0 -onroot $randpic > /dev/null &`; exit; } else { # If backdrop is called with an argument, use the argument # as the backdrop. `/usr/bin/Esetroot -display :0.0 $ARGV[0]`; #`/usr/bin/X11/xli -display :0.0 -onroot $ARGV[0] > /dev/null &`; exit; } } # William O'Higgins yam@nerd.cx