diff options
author | Joe <bousset.rudy@gmail.com> | 2022-08-13 15:46:37 +0200 |
---|---|---|
committer | Joe <bousset.rudy@gmail.com> | 2022-08-13 15:46:37 +0200 |
commit | c9f0b7d941344474fe4228b7db28a2f1cd677ccb (patch) | |
tree | 09d88a36e56ab3ea76f36a00abed2d1de1025632 /.local/bin | |
parent | update (diff) | |
download | dotfiles-bsd-c9f0b7d941344474fe4228b7db28a2f1cd677ccb.tar.gz dotfiles-bsd-c9f0b7d941344474fe4228b7db28a2f1cd677ccb.tar.bz2 dotfiles-bsd-c9f0b7d941344474fe4228b7db28a2f1cd677ccb.tar.xz dotfiles-bsd-c9f0b7d941344474fe4228b7db28a2f1cd677ccb.tar.zst dotfiles-bsd-c9f0b7d941344474fe4228b7db28a2f1cd677ccb.zip |
compat
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/dmlog | 23 |
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'); } } |