summaryrefslogtreecommitdiffstats
path: root/.local/bin/powercmd
diff options
context:
space:
mode:
authorJoe <rrbo@proton.me>2023-02-14 14:49:03 +0100
committerJoe <rrbo@proton.me>2023-02-14 14:49:03 +0100
commit5d4f5057ac8b42a76ae98562a74478e7d0550449 (patch)
tree2fc467abf749d536a2043a3bc6433c29b51b7dbe /.local/bin/powercmd
parentup (diff)
downloaddotfiles-bsd-5d4f5057ac8b42a76ae98562a74478e7d0550449.tar.gz
dotfiles-bsd-5d4f5057ac8b42a76ae98562a74478e7d0550449.tar.bz2
dotfiles-bsd-5d4f5057ac8b42a76ae98562a74478e7d0550449.tar.xz
dotfiles-bsd-5d4f5057ac8b42a76ae98562a74478e7d0550449.tar.zst
dotfiles-bsd-5d4f5057ac8b42a76ae98562a74478e7d0550449.zip
up
Diffstat (limited to '.local/bin/powercmd')
-rwxr-xr-x.local/bin/powercmd48
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
;;
*)