From: Nick Bowler Date: Sun, 1 Jun 2008 00:39:38 +0000 (-0400) Subject: Add random background selector script. X-Git-Url: http://git.draconx.ca/gitweb/fvwmconf.git/commitdiff_plain/9549554c2149ffc7cc94788a967005be56dc46d6 Add random background selector script. --- diff --git a/scripts/randombg.pl b/scripts/randombg.pl new file mode 100755 index 0000000..941ebe7 --- /dev/null +++ b/scripts/randombg.pl @@ -0,0 +1,21 @@ +#!/usr/bin/perl + +use strict; + +my $FVWM = (defined $ENV{FVWM_USERDIR}) ? $ENV{FVWM_USERDIR} + : $ENV{HOME}."/.fvwm"; + +die ("usage: randombg.pl ") if (! -d $ARGV[0]); + +open XASPECT, "-|", "$FVWM/scripts/C/xaspect", "-dimensions"; +my $aspect = ; +close XASPECT; +die ("Incompetent use of xaspect") if ($?); + +$aspect =~ s/(^\s*)|(\s*$)//g; + +opendir WALLPAPER, $ARGV[0]; +my @dir = grep(/\Q$aspect\E\.png$/, readdir WALLPAPER); +closedir WALLPAPER; + +print $ARGV[0] . "/" . $dir[int(rand(@dir))] . "\n";