diff options
author | Joe <rbo@gmx.us> | 2024-06-22 14:24:43 +0200 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-06-22 14:24:43 +0200 |
commit | c5264f42556c153179541d030442f6992770ff23 (patch) | |
tree | cbb3934dafd8f39e55bd2a56c3fbde5c50ccebde /.local/bin | |
parent | up (diff) | |
download | dotfiles-bsd-c5264f42556c153179541d030442f6992770ff23.tar.gz dotfiles-bsd-c5264f42556c153179541d030442f6992770ff23.tar.bz2 dotfiles-bsd-c5264f42556c153179541d030442f6992770ff23.tar.xz dotfiles-bsd-c5264f42556c153179541d030442f6992770ff23.tar.zst dotfiles-bsd-c5264f42556c153179541d030442f6992770ff23.zip |
up
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/dmlog | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/.local/bin/dmlog b/.local/bin/dmlog index a4c0182..6117f55 100755 --- a/.local/bin/dmlog +++ b/.local/bin/dmlog @@ -2,6 +2,8 @@ use strict; use warnings; +use Sys::Hostname; + use constant OS => `uname | tr -d '\n'`; use constant { SLOCK_PATH => 'slock', @@ -11,7 +13,7 @@ use constant { SHUTDOWN_PATH => '/sbin/shutdown', LOGINCTL_PATH => '/usr/bin/loginctl', NOTIF_PATH => 'notify-send', - EMACS_PATH => 'emacsclient' + HOSTNAME => (split /\./, hostname()) }; use constant LIST => [ 'Lock screen', @@ -65,7 +67,10 @@ sub action ' G\'night, partner!' ); sleep 2; - if (OS eq 'Linux') { + if (HOSTNAME eq 'mother') { + exec(LOGINCTL_PATH, 'suspend'); + } + elsif (HOSTNAME eq 'po-rbo') { exec('systemctl', 'suspend'); } exec(ACPI_PATH, '-s', '3'); @@ -73,8 +78,7 @@ sub action } elsif ($var eq ${+LIST}[2]) { if (confirm($var) == 1) { - system(EMACS_PATH, '-e', '"(save-buffers-kill-terminal)"'); - if (OS eq 'Linux') { + if (HOSTNAME eq 'mother') { exec(LOGINCTL_PATH, 'terminate-session', 'self'); } exec(KILL_PATH, 'dwm'); @@ -82,8 +86,10 @@ sub action } elsif ($var eq ${+LIST}[3]) { if (confirm($var) == 1) { - system(EMACS_PATH, '-e', '"(save-buffers-kill-terminal)"'); - if (OS eq 'Linux') { + if (HOSTNAME eq 'mother') { + exec(LOGINCTL_PATH, 'reboot'); + } + elsif (HOSTNAME eq 'po-rbo') { exec('systemctl', 'reboot'); } system( @@ -98,7 +104,6 @@ sub action } elsif ($var eq ${+LIST}[4]) { if (confirm($var) == 1) { - system(EMACS_PATH, '-e', '"(save-buffers-kill-terminal)"'); system( NOTIF_PATH, '-u', @@ -107,7 +112,10 @@ sub action ' Farewell, partner!' ); sleep 2; - if (OS eq 'Linux') { + if (HOSTNAME eq 'mother') { + exec(LOGINCTL_PATH, 'poweroff'); + } + elsif (HOSTNAME eq 'po-rbo') { exec('systemctl', 'poweroff'); } exec(SHUTDOWN_PATH, '-p', 'now'); |