diff options
Diffstat (limited to '')
-rwxr-xr-x | .local/bin/powercmd | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/.local/bin/powercmd b/.local/bin/powercmd index 9b83e4b..371f911 100755 --- a/.local/bin/powercmd +++ b/.local/bin/powercmd @@ -2,25 +2,11 @@ [ -z "$1" ] && echo "no arg" && exit 1 -os="$(uname)" - -if [ "$os" = "Linux" ]; then - grep "Artix" /etc/issue >/dev/null 2>&1 && os=1 || os=2 -elif [ "$os" = "FreeBSD" ]; then - os=3 -else - echo "unknown OS" - exit 1 -fi - -# 1: Artix -# 2: Pop OS -# 3: FreeBSD - -case $os in - 1) icon=" " ;; - 2) icon=" " ;; - 3) icon=" " ;; +host="$(hostname -s)" +case $host in + mother) icon=" " ;; + po-rbo) icon=" " ;; + fbsd-tp) icon=" " ;; esac case $1 in @@ -30,30 +16,30 @@ case $1 in sleep 1 xscreensaver-command -lock sleep 5 - case $os in - 1) loginctl suspend ;; - 2) systemctl suspend ;; - 3) acpiconf -s 3 ;; + case $host in + mother) loginctl suspend ;; + po-rbo) systemctl suspend ;; + fbsd-tp) acpiconf -s 3 ;; esac ;; "reboot") emacsclient -e '"(save-buffers-kill-emacs)"' >/dev/null 2>&1 notify-send -u normal reboot "$icon Rebootin' now!" sleep 2 - case $os in - 1) loginctl reboot ;; - 2) systemctl reboot ;; - 3) shutdown -r now ;; + case $host in + mother) loginctl reboot ;; + po-rbo) systemctl reboot ;; + fbsd-tp) shutdown -r now ;; esac ;; "poweroff") emacsclient -e '"(save-buffers-kill-emacs)"' >/dev/null 2>&1 notify-send -u normal poweroff "$icon Farewell, partner!" sleep 2 - case $os in - 1) loginctl poweroff ;; - 2) systemctl poweroff ;; - 3) shutdown -p now ;; + case $host in + mother) loginctl poweroff ;; + po-rbo) systemctl poweroff ;; + fbsd-tp) shutdown -p now ;; esac ;; *) |