X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=bin%2Fsetbg;h=55f2d029742ebea21bf8519b3644cc117803e42b;hb=6523d45db2e04f44fb4009ca8549d56226559f8c;hp=01fda58b986a4fbc67146e5614d80ab8a4e6cfe6;hpb=b5908dd87cbfc53926d81f04d3a4d12949a9b2a3;p=clearscm.git diff --git a/bin/setbg b/bin/setbg index 01fda58..55f2d02 100755 --- a/bin/setbg +++ b/bin/setbg @@ -130,11 +130,12 @@ sub fillPictures () { $totals{bgdirs} = 0; for (@{$opts{bgdirs}}) { - my @pics = `find "$_" -type f -name "*.jpg"`; + my ($status, @pics) = Execute "find \"$_\" -type f"; chomp @pics; - push @images, @pics; + push @images, grep(/jpg$|png$|gif$/i, @pics); + push @{$opts{bgdircnt}}, scalar @pics; $totals{bgdirs}++; @@ -155,7 +156,7 @@ sub updateSetBG ($$) { close $setbg; - my $msg = localtime() . ':$bgimage'; + my $msg = localtime() . ":$bgimage"; $msg .= " lock:$lockimage" if $opts{lockscreen}; open my $hist, '>>', "$ENV{HOME}/.$FindBin::Script.hist" @@ -233,11 +234,17 @@ while () { my $bgimage = escapeHTML ($images[int (rand $#images)]); my $lockimage = escapeHTML ($images[int (rand $#images)]); + my $monitorIsOn; + + my ($status, @output) = Execute("xset q | grep Monitor | awk '{print \$3}'"); + + next if $status or $output[0] eq 'Off'; + my $cmd = "$setbg $setbgOpts$bgimage\" 2> /dev/null"; - my @output = `$cmd`; + ($status, @output) = Execute $cmd; - if ($? != 0) { + if ($status) { error "Trying to set background - command used \"$cmd\"\n\nOutput\n\n" . join "\n", @output; $totals{errors}++; @@ -248,9 +255,9 @@ while () { if ($opts{lockscreen}) { $cmd = "$setbg $setLockOpts$lockimage\" 2> /dev/null"; - @output = `$cmd`; + ($status, @output) = Execute $cmd; - if ($? != 0) { + if ($status != 0) { error "Trying to set lock screen - command used \"$cmd\"\n\nOutput\n\n" . join "\n", @output; $totals{errors}++;