summaryrefslogtreecommitdiffstats
path: root/.local/bin/dmlog
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/dmlog')
-rwxr-xr-x.local/bin/dmlog50
1 files changed, 37 insertions, 13 deletions
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') {