From 9549554c2149ffc7cc94788a967005be56dc46d6 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 31 May 2008 20:39:38 -0400 Subject: [PATCH] Add random background selector script. --- scripts/randombg.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 scripts/randombg.pl 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"; -- 2.43.0