Re-disable Journald, -> distrobox

This commit is contained in:
John Mertz 2023-01-09 11:52:03 -05:00
parent 00eef39441
commit 2b83934283
Signed by: jpm
GPG Key ID: E9C5EA2D867501AB
2 changed files with 12 additions and 37 deletions

View File

@ -66,7 +66,7 @@ sub new
return bless { %args }; return bless { %args };
} }
$args{pidfile} = "/tmp/$ENV{USER}-wallpaper.pid"; my $wp = new("Wallpapers");
if (-e $wp->{pidfile}) { if (-e $wp->{pidfile}) {
if (-r $wp->{pidfile}) { if (-r $wp->{pidfile}) {
@ -281,12 +281,12 @@ sub do_log
# Journald is borked. Just don't bother logging # Journald is borked. Just don't bother logging
return 0; return 0;
if ($self->{daemon}) { if ($self->{daemon}) {
use Log::Journald qw(send); #use Log::Journald qw(send);
send( #send(
PRIORITY => ERROR->{$level}, #PRIORITY => ERROR->{$level},
MESSAGE => $msg, #MESSAGE => $msg,
PERL_PACKAGE => 'Sway Wallpapers' #PERL_PACKAGE => 'Sway Wallpapers'
) || warn "Could not send log ($level $msg): $!"; #) || warn "Could not send log ($level $msg): $!";
if ($die) { if ($die) {
$msg = '(FATAL) ' . $msg; $msg = '(FATAL) ' . $msg;
exit(1); exit(1);
@ -374,8 +374,6 @@ sub run
################################################################################ ################################################################################
# Collect arguments # Collect arguments
################################################################################ ################################################################################
my $wp = new("Wallpapers");
my @targets; my @targets;
my $daemon; my $daemon;
my $delay; my $delay;
@ -383,7 +381,6 @@ my $crop;
my $path; my $path;
my $verbose; my $verbose;
my $recursive = 0; my $recursive = 0;
while (my $arg = shift(@ARGV)) { while (my $arg = shift(@ARGV)) {
if ($arg eq '-h' || $arg eq '--help') { if ($arg eq '-h' || $arg eq '--help') {
$wp->usage(); $wp->usage();
@ -441,6 +438,7 @@ die "Invalid wallpaper path '$path'. Not a directory." if (defined($path) && !-d
die "Invalid verbosity level: '$verbose'\n" if (defined($verbose) && $verbose !~ m/^[1-8]$/); die "Invalid verbosity level: '$verbose'\n" if (defined($verbose) && $verbose !~ m/^[1-8]$/);
$wp->do_log("LOG_DEBUG", "Configuring object"); $wp->do_log("LOG_DEBUG", "Configuring object");
$wp->{targets} = \@targets || undef;
$wp->{daemon} = $daemon || 0; $wp->{daemon} = $daemon || 0;
$wp->{path} = $path || "$ENV{HOME}/wallpapers"; $wp->{path} = $path || "$ENV{HOME}/wallpapers";
$wp->{crop} = $crop || 1; $wp->{crop} = $crop || 1;
@ -497,28 +495,4 @@ do {
# If we made it to here, it was not daemonized. Output errors and exit # If we made it to here, it was not daemonized. Output errors and exit
$wp->do_log("LOG_DEBUG", "Finishing") unless ($wp->{daemon}); $wp->do_log("LOG_DEBUG", "Finishing") unless ($wp->{daemon});
################################################################################
# Signals
################################################################################
# SIGUSR reset the timer, force immediate reload, continue looping
$SIG{USR1} = sub {
alarm 0;
$wp->do_log("LOG_INFO", "Reloading due to SIGUSR1");
};
# SIGTERM reset the timer, clean pid, and allow for the main loop to finish run
$SIG{TERM} = sub {
$wp->do_log("LOG_INFO", "Going down clean due to SIGTERM");
clean($wp);
$wp->{daemon} = 0;
};
# SIGKILL clean pid then exit immediately
$SIG{KILL} = sub {
$wp->do_log("LOG_INFO", "Hard kill with SIGKILL, attempting to remove pidfile");
clean($wp);
exit(0);
};
exit(0); exit(0);

View File

@ -5,7 +5,8 @@ Description=Rotate through cropped wallpapers for %u
Type=forking Type=forking
PIDFile=/tmp/%u-wallpaper.pid PIDFile=/tmp/%u-wallpaper.pid
WorkingDirectory=/tmp WorkingDirectory=/tmp
ExecStart=/var/home/%u/scripts/sway/wallpaper.pl -d --path=/home/jpm/wallpapers ExecStart=/usr/bin/distrobox enter debian12 -- "$HOME/scripts/sway/wallpaper.pl -d --path=/home/jpm/wallpapers"
#ExecStart=/var/home/%u/scripts/sway/wallpaper.pl -d --path=/home/jpm/wallpapers
Restart=always Restart=always
[Install] [Install]