summaryrefslogtreecommitdiffstats
path: root/.local/bin/dmlog
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/dmlog')
-rwxr-xr-x.local/bin/dmlog23
1 files changed, 19 insertions, 4 deletions
diff --git a/.local/bin/dmlog b/.local/bin/dmlog
index a2e8458..e110980 100755
--- a/.local/bin/dmlog
+++ b/.local/bin/dmlog
@@ -2,12 +2,14 @@
use strict;
use warnings;
+use constant OS => `uname | tr -d '\n'`;
use constant {
SLOCK_PATH => 'slock',
XSCREENSAVER_PATH => 'xscreensaver-command',
- ACPI_PATH => 'acpiconf',
- KILL_PATH => 'killall',
- SHUTDOWN_PATH => 'shutdown',
+ ACPI_PATH => '/usr/sbin/acpiconf',
+ KILL_PATH => '/usr/bin/killall',
+ SHUTDOWN_PATH => '/sbin/shutdown',
+ LOGINCTL_PATH => '/usr/bin/loginctl',
NOTIF_PATH => 'notify-send',
EMACS_PATH => 'emacsclient'
};
@@ -61,19 +63,29 @@ sub action
'normal',
'shutdown',
' G\'night, partner!'
- );
+ );
+ sleep 2;
+ if (OS eq 'Linux') {
+ exec(LOGINCTL_PATH, 'suspend');
+ }
exec(ACPI_PATH, '-s', '3');
}
}
elsif ($var eq ${+LIST}[2]) {
if (confirm($var) == 1) {
system(EMACS_PATH, '-e', '(save-buffers-kill-terminal)');
+ if (OS eq 'Linux') {
+ exec(LOGINCTL_PATH, 'terminate-session', 'self');
+ }
exec(KILL_PATH, 'dwm');
}
}
elsif ($var eq ${+LIST}[3]) {
if (confirm($var) == 1) {
system(EMACS_PATH, '-e', '(save-buffers-kill-terminal)');
+ if (OS eq 'Linux') {
+ exec(LOGINCTL_PATH, 'reboot');
+ }
exec(SHUTDOWN_PATH, '-r', 'now');
}
}
@@ -88,6 +100,9 @@ sub action
' Farewell, partner!'
);
sleep 2;
+ if (OS eq 'Linux') {
+ exec(LOGINCTL_PATH, 'poweroff');
+ }
exec(SHUTDOWN_PATH, '-p', 'now');
}
}