]> git.draconx.ca Git - fvwmconf.git/blob - scripts/randombg.pl
Use mpdexec for key bindings.
[fvwmconf.git] / scripts / randombg.pl
1 #!/usr/bin/perl
2
3 use strict;
4
5 my $FVWM = (defined $ENV{FVWM_USERDIR}) ? $ENV{FVWM_USERDIR}
6                                         : $ENV{HOME}."/.fvwm";
7
8 die ("usage: randombg.pl <directory>") if (! -d $ARGV[0]);
9
10 open XASPECT, "-|", "$FVWM/scripts/C/xaspect", "-dimensions";
11 my $aspect = <XASPECT>;
12 close XASPECT;
13 die ("Incompetent use of xaspect") if ($?);
14
15 $aspect =~ s/(^\s*)|(\s*$)//g;
16
17 opendir WALLPAPER, $ARGV[0];
18 my @dir = grep(/\Q$aspect\E\.png$/, readdir WALLPAPER);
19 closedir WALLPAPER;
20
21 print $ARGV[0] . "/" . $dir[int(rand(@dir))] . "\n";