+ if ($pickNewImages) {
+ $bgimage = escapeHTML ($images[int (rand $#images)]);
+ $lockimage = escapeHTML ($images[int (rand $#images)]);
+ } # if
+
+ my $monitorIsOn;
+
+ my ($status, @output) = Execute("xset q | grep Monitor | awk '{print \$3}'");
+
+ if ($status or $output[0] eq 'Off') {
+ writeHistory ":Monitor off, not setting background to $bgimage - will keep trying";
+
+ $pickNewImages = 0;
+ } else {
+ $pickNewImages = 1;
+
+ my $cmd = $opts{mate} ? "$setbg $setbgOpts\"$bgimage\" 2> /dev/null"
+ : "$setbg $setbgOpts$bgimage\" 2> /dev/null";
+
+ ($status, @output) = Execute $cmd;
+
+ if ($status) {
+ error "Trying to set background - command used \"$cmd\"\n\nOutput\n\n" .
+ join "\n", @output;
+ $totals{errors}++;
+ } else {
+ $totals{'Images displayed'}++;
+ } # if
+
+ if ($opts{lockscreen}) {
+ $cmd = $opts{mate} ? "$setbg $setLockOpts\"$lockimage\" 2> /dev/null"
+ : "$setbg $setLockOpts$lockimage\" 2> /dev/null";
+
+ ($status, @output) = Execute $cmd;
+
+ if ($status != 0) {
+ error "Trying to set lock screen - command used \"$cmd\"\n\nOutput\n\n" .
+ join "\n", @output;
+ $totals{errors}++;
+ } else {
+ $totals{'Lock screens displayed'}++;
+ } # if
+ } # if
+
+ updateSetBG $bgimage, $lockimage;
+ } # if