X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=bin%2Fsetbg;h=55f2d029742ebea21bf8519b3644cc117803e42b;hb=92e785ae8470b83a6750251d824a96bbd88c4df0;hp=a09e5f01e7bf3fcdfc4c694ad41f9bdf37fcf37b;hpb=d58045351725edca8fcb05a78c4b80865d7c3cf3;p=clearscm.git diff --git a/bin/setbg b/bin/setbg index a09e5f0..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}++; @@ -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}++;