projects
/
clearscm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c2dd51b
)
Updated setbg to properly handle the case when the monitor is off
author
Andrew DeFaria
<Andrew@DeFaria.com>
Mon, 10 Aug 2020 23:25:11 +0000
(16:25 -0700)
committer
Andrew DeFaria
<Andrew@DeFaria.com>
Mon, 10 Aug 2020 23:25:11 +0000
(16:25 -0700)
bin/setbg
patch
|
blob
|
history
diff --git
a/bin/setbg
b/bin/setbg
index
55f2d02
..
93a339a
100755
(executable)
--- a/
bin/setbg
+++ b/
bin/setbg
@@
-145,8
+145,20
@@
sub fillPictures () {
return @images;
} # fillPictures
return @images;
} # fillPictures
+sub writeHistory($) {
+ my ($msg) = @_;
-sub updateSetBG ($$) {
+ open my $hist, '>>', "$ENV{HOME}/.$FindBin::Script.hist"
+ or error "Unable to open $ENV{HOME}/.$FindBin::Script.hist for append - $!", 1;
+
+ $msg = localtime() . $msg;
+
+ display $msg, $hist;
+
+ close $hist;
+} # writeHistory
+
+sub updateSetBG($$) {
my ($bgimage, $lockimage) = @_;
open my $setbg, '>', "$ENV{HOME}/.$FindBin::Script"
my ($bgimage, $lockimage) = @_;
open my $setbg, '>', "$ENV{HOME}/.$FindBin::Script"
@@
-156,15
+168,10
@@
sub updateSetBG ($$) {
close $setbg;
close $setbg;
- my $msg =
localtime() .
":$bgimage";
+ my $msg = ":$bgimage";
$msg .= " lock:$lockimage" if $opts{lockscreen};
$msg .= " lock:$lockimage" if $opts{lockscreen};
- open my $hist, '>>', "$ENV{HOME}/.$FindBin::Script.hist"
- or error "Unable to open $ENV{HOME}/.$FindBin::Script.hist for append - $!", 1;
-
- display $msg, $hist;
-
- close $hist;
+ writeHistory $msg;
return;
} # updateSetBG
return;
} # updateSetBG
@@
-238,37
+245,39
@@
while () {
my ($status, @output) = Execute("xset q | grep Monitor | awk '{print \$3}'");
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";
-
- ($status, @output) = Execute $cmd;
-
- if ($status) {
- error "Trying to set background - command used \"$cmd\"\n\nOutput\n\n" .
- join "\n", @output;
- $totals{errors}++;
+ if ($status or $output[0] eq 'Off') {
+ writeHistory ":Monitor off, not setting background to $bgimage";
} else {
} else {
- $totals{'Images displayed'}++;
- } # if
-
- if ($opts{lockscreen}) {
- $cmd = "$setbg $setLockOpts$lockimage\" 2> /dev/null";
+ my $cmd = "$setbg $setbgOpts$bgimage\" 2> /dev/null";
($status, @output) = Execute $cmd;
($status, @output) = Execute $cmd;
- if ($status
!= 0
) {
- error "Trying to set
lock screen - command used \"$cmd\"\n\nOutput\n\n" .
+ if ($status) {
+ error "Trying to set
background - command used \"$cmd\"\n\nOutput\n\n" .
join "\n", @output;
$totals{errors}++;
} else {
join "\n", @output;
$totals{errors}++;
} else {
- $totals{'
Lock screen
s displayed'}++;
+ $totals{'
Image
s displayed'}++;
} # if
} # if
- } # if
- updateSetBG $bgimage, $lockimage;
+ if ($opts{lockscreen}) {
+ $cmd = "$setbg $setLockOpts$lockimage\" 2> /dev/null";
- displayStats;
+ ($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;
+
+ displayStats;
+ } # if
$today = YMD;
$today = YMD;