diff options
Diffstat (limited to '')
| -rwxr-xr-x | .local/bin/dmlog | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/.local/bin/dmlog b/.local/bin/dmlog index c6a52f7..6a92258 100755 --- a/.local/bin/dmlog +++ b/.local/bin/dmlog @@ -79,55 +79,57 @@ 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 { - # system(SLOCK_PATH); - # notify("g'day, partner!"); - # return; - # } - if (HOSTNAME eq 'mother') { - # setsid(); - # sleep 4; - # exec(LOGINCTL_PATH, 'suspend'); - } - } - else { + if (confirm($var, $color) == 1) { + notify("g'night, partner!"); sleep 1; - if (HOSTNAME eq 'mother') { - 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; + $pid = fork(); + if (not $pid) { + # 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 { 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; + if (HOSTNAME eq 'mother') { + 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'); } - sleep 1; - exec(LOGINCTL_PATH, 'suspend'); - } - elsif (HOSTNAME eq 'po-rbo') { - exec('doas', 'systemctl', 'suspend'); + elsif (HOSTNAME eq 'po-rbo') { + exec('doas', 'systemctl', 'suspend'); + } + exec(ACPI_PATH, '-s', '3'); } - exec(ACPI_PATH, '-s', '3'); } } elsif ($var eq ${+LIST}[2]) { |
