X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=bin%2Fsetbg;h=e3f5a46bb4d3d346e8e2e9b9ee74c2b4e4bdef58;hb=6b78619b15c8671ad67e2aa8eb64068d5adb1758;hp=ddfa756642f65d401c446feda3ef4ee68a695f7e;hpb=3b50292664f76044bace93c83bb9dbf43d9731a2;p=clearscm.git diff --git a/bin/setbg b/bin/setbg index ddfa756..e3f5a46 100755 --- a/bin/setbg +++ b/bin/setbg @@ -57,6 +57,7 @@ use warnings; use FindBin; use Getopt::Long; use Proc::ProcessTable; +use CGI qw/:standard/; use lib "$FindBin::Bin/../lib"; @@ -82,24 +83,34 @@ $0 = "$FindBin::Script " . join ' ', @ARGV; verbose "$FindBin::Script v$VERSION"; my $sleep = 60 * 60; -my $imgDir = $ENV{SETBG_DIR} ? $ENV{SETBG_DIR} : '/web/Pictures'; +my @imgDir; GetOptions ( - 'usage' => sub { Usage }, - 'verbose' => sub { set_verbose }, - 'debug' => sub { set_debug }, - 'sleep=i' => \$sleep, - 'bgdir=s' => \$imgDir, + 'usage' => sub { Usage }, + 'verbose' => sub { set_verbose }, + 'debug' => sub { set_debug }, + 'sleep=i' => \$sleep, + 'bgdir=s' => \@imgDir, ) || Usage; -error "$imgDir is not a directory", 1 unless -d $imgDir; +foreach (@imgDir) { + error "$_ is not a directory", 1 unless -d $_; +} # foreach # Using gsettings my $setbg = "gsettings"; my $setbgOpts = "set org.gnome.desktop.background picture-uri \"file://"; -chomp (my @images = `find $imgDir -type f -name "*.jpg"`); +my @images; + +foreach (@imgDir) { + my @pics = `find "$_" -type f -name "*.jpg"`; + chomp @pics; + push @images, @pics; +} # foreach +Usage "No images to display. Must specify -imgDir" unless @images; + sub SwitchWallPaper { # We don't need to do anything here, just handle the interrupt and # let the while loop continue. @@ -113,7 +124,7 @@ my $debugger = $DB::OUT; EnterDaemonMode unless defined $DB::OUT; while () { - my $image = $images[int (rand $#images)]; + my $image = escapeHTML ($images[int (rand $#images)]); open my $log, '>', "$ENV{HOME}/.$FindBin::Script" or error "Unable to open $ENV{HOME}/.setbg for writing - $!", 1;