]> git.draconx.ca Git - fvwmconf.git/commitdiff
Add random background selector script.
authorNick Bowler <draconx@gmail.com>
Sun, 1 Jun 2008 00:39:38 +0000 (20:39 -0400)
committerNick Bowler <draconx@gmail.com>
Sun, 1 Jun 2008 00:39:38 +0000 (20:39 -0400)
scripts/randombg.pl [new file with mode: 0755]

diff --git a/scripts/randombg.pl b/scripts/randombg.pl
new file mode 100755 (executable)
index 0000000..941ebe7
--- /dev/null
@@ -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 <directory>") if (! -d $ARGV[0]);
+
+open XASPECT, "-|", "$FVWM/scripts/C/xaspect", "-dimensions";
+my $aspect = <XASPECT>;
+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";