From e0d2d242853ab2f20683666bea97034594fae296 Mon Sep 17 00:00:00 2001 From: joe Date: Sun, 9 Nov 2025 20:08:02 +0100 Subject: up --- .local/bin/dmlog | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to '.local/bin/dmlog') diff --git a/.local/bin/dmlog b/.local/bin/dmlog index 5b99d4f..c6a52f7 100755 --- a/.local/bin/dmlog +++ b/.local/bin/dmlog @@ -79,25 +79,49 @@ sub action } } elsif ($var eq ${+LIST}[1]) { + notify("g'night, partner!"); + sleep 1; $pid = fork(); if (not $pid) { - if (defined $ENV{WAYLAND_DISPLAY}) { - exec("waylock", - "-init-color", "0x1d2021", - "-input-color", "0xd79921", - "-fail-color", "0xcc241d"); - } - else { - exec(XSCREENSAVER_PATH, '-lock'); + # if (defined $ENV{WAYLAND_DISPLAY}) { + # exec("waylock", + # "-init-color", "0x1d2021", + # "-input-color", "0xd79921", + # "-fail-color", "0xcc241d"); + # } + # else { + # system(SLOCK_PATH); + # notify("g'day, partner!"); + # return; + # } + if (HOSTNAME eq 'mother') { + # setsid(); + # sleep 4; + # exec(LOGINCTL_PATH, 'suspend'); } } else { - notify("g'night, partner!"); - sleep 2; + sleep 1; if (HOSTNAME eq 'mother') { - system(LOGINCTL_PATH, 'terminate-session', 'self'); - # system('umount', '-f', '/var/dev/ceres'); - sleep 2 + my $user = 'jozan'; + my $self = $$; + my @pids = map { s/^\s+|\s+$//gr } qx{ps -u $user -o pid=}; + for my $pid (@pids) { + next unless $pid =~ /^\d+$/; + next if $pid == $self; + next if $pid == 1; # don't try to kill init + kill 'TERM', $pid; + } + sleep 1; + for my $pid (@pids) { + next unless $pid =~ /^\d+$/; + next if $pid == $self; + next if $pid == 1; + if (kill 0, $pid) { # process still exists + kill 'KILL', $pid; + } + } + sleep 1; exec(LOGINCTL_PATH, 'suspend'); } elsif (HOSTNAME eq 'po-rbo') { -- cgit v1.2.3