http://qs321.pair.com?node_id=336558

Randomly rotate WindowMaker background image.   For Debian use, place script in /etc/init.d/ directory, and symlink from /etc/rcS.d/, or else call the script from cron reboot jobs.

Woof - four months is too long to go between perlings.   8^P

As always, critique is welcome and requested.

Update: Thanks to Corion, chip, theorbtwo, and dws for CB help in getting my brain back into perl mode with this.

#!/usr/bin/perl5.8.0 -w # wmb_rotate.pl # pod at tail use strict; use Cwd; # use Module::Versions::Report; my $dir = '/usr/share/WindowMaker/Backgrounds'; my $linkname = '00rotation_image'; my $randfile = ''; print "Rotating WindowMaker background image... "; chdir $dir or die "$!\n"; $randfile = RandFile($dir) until (-f $randfile && -B _); if (-e $linkname){ die "$!\n" unless (-l $linkname && -w _); unlink $linkname or die "$!\n"; } symlink $randfile, $linkname or die "$!\n"; print "done.\n"; sub RandFile { opendir F, $_[0] or die "$!\n"; my @F = grep { /^\w.*/ } readdir F; return $F[rand @F]; } =head1 TITLE wmb_rotate.pl =head1 SYNOPSIS Place script in /etc/init.d directory, symlink from /etc/rcS.d, point WindowMaker background image to $linkname Or call script from cron reboot job =head1 DESCRIPTION Randomly rotate WindowMaker background images. =head1 TODO Check for -f and -B from within &RandFile() ...profit! =head1 UPDATE 2004-03-15 12:35 CST Test against Perl 5.6.1 Revise logic for checks - exists, writable, symlink Trivial code correction and pod tweaks Post to PM Snippets Rewrite as small script instead of one-liner 2004-03-13 Initial working code =head1 TESTED Debian 3.0r2 Perl 5.8.0 5.6.1 strict 1.02 1.01 warnings 1.00 Cwd 2.06 2.04 Modules::Versions::Report 1.02 =head1 BUGS None that I know of =head1 CREDITS Thanks to Corion, chip, theorbtwo, and dws for CB help in getting my brain back into perl mode with this. And to some guy named vroom. perl -e 'opendir F,".";@F=readdir F;print $F[rand @F];' ls -l | perl -e '@F=<>;print $F[rand @F];' =head1 AUTHOR ybiC =cut