From 836241d75890775689fcecee6c3feae3e3774010 Mon Sep 17 00:00:00 2001 From: Andrew DeFaria Date: Wed, 13 May 2020 18:24:00 -0700 Subject: [PATCH] Added ability to set lock screen to setbg Also added some more files to clean in /tmp --- bin/setbg | 32 +++++++++++++++++++++++--------- etc/cleantmp.conf | 3 +++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/bin/setbg b/bin/setbg index a6490fd..86a647a 100755 --- a/bin/setbg +++ b/bin/setbg @@ -143,17 +143,17 @@ sub fillPictures () { return @images; } # fillPictures -sub updateSetBG ($) { - my ($image) = @_; +sub updateSetBG ($$) { + my ($bgimage, $lockimage) = @_; open my $setbg, '>', "$ENV{HOME}/.$FindBin::Script" or error "Unable to open $ENV{HOME}/.$FindBin::Script for writing - $!", 1; - display $image, $setbg; + display $bgimage, $setbg; close $setbg; - my $msg = localtime() . ":$image"; + my $msg = localtime() . ":$bgimage lock:$lockimage"; open my $hist, '>>', "$ENV{HOME}/.$FindBin::Script.hist" or error "Unable to open $ENV{HOME}/.$FindBin::Script.hist for append - $!", 1; @@ -207,8 +207,9 @@ for (my $i = 0; $i < scalar @{$opts{bgdirs}}; $i++) { } # for # Using gsettings -my $setbg = "gsettings"; -my $setbgOpts= "set org.gnome.desktop.background picture-uri \"file://"; +my $setbg = "gsettings"; +my $setbgOpts = "set org.gnome.desktop.background picture-uri \"file://"; +my $setLockOpts = "set org.gnome.desktop.screensaver picture-uri \"file://"; my @images = fillPictures; @@ -225,9 +226,10 @@ truncate "$ENV{HOME}/.$FindBin::Script.hist", 0; EnterDaemonMode unless defined $DB::OUT; while () { - my $image = escapeHTML ($images[int (rand $#images)]); + my $bgimage = escapeHTML ($images[int (rand $#images)]); + my $lockimage = escapeHTML ($images[int (rand $#images)]); - my $cmd = "$setbg $setbgOpts$image\" 2> /dev/null"; + my $cmd = "$setbg $setbgOpts$bgimage\" 2> /dev/null"; my @output = `$cmd`; @@ -237,10 +239,22 @@ while () { $totals{errors}++; } else { $totals{'Images displayed'}++; + } # if + + $cmd = "$setbg $setLockOpts$lockimage\" 2> /dev/null"; - updateSetBG $image; + @output = `$cmd`; + + if ($? != 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 + updateSetBG $bgimage, $lockimage; + displayStats; $today = YMD; diff --git a/etc/cleantmp.conf b/etc/cleantmp.conf index 91d1be0..7f6a471 100644 --- a/etc/cleantmp.conf +++ b/etc/cleantmp.conf @@ -27,3 +27,6 @@ MozillaMailnews snap.* ssh-.* config-err.* +Temp-* +tmp* +tracker-* -- 2.17.1