From e0126eea04c6d0de501af304c30d0276d78799bb Mon Sep 17 00:00:00 2001 From: Andrew DeFaria Date: Wed, 7 Oct 2020 15:06:45 -0700 Subject: [PATCH] Changed to not try new images while the monitor is off --- bin/setbg | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/setbg b/bin/setbg index 93a339a..e36a1a7 100755 --- a/bin/setbg +++ b/bin/setbg @@ -237,17 +237,27 @@ truncate "$ENV{HOME}/.$FindBin::Script.hist", 0; EnterDaemonMode unless defined $DB::OUT; +my $pickNewImages = 1; + while () { - my $bgimage = escapeHTML ($images[int (rand $#images)]); - my $lockimage = escapeHTML ($images[int (rand $#images)]); + my ($bgimage, $lockimage); + + 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"; + writeHistory ":Monitor off, not setting background to $bgimage - will keep trying"; + + $pickNewImages = 0; } else { + $pickNewImages = 1; + my $cmd = "$setbg $setbgOpts$bgimage\" 2> /dev/null"; ($status, @output) = Execute $cmd; -- 2.17.1