summaryrefslogtreecommitdiffstats
path: root/.local/bin/powercmd
diff options
context:
space:
mode:
authorJoe <rrbo@proton.me>2023-01-31 15:26:57 +0100
committerJoe <rrbo@proton.me>2023-01-31 15:26:57 +0100
commit22ba7c46f959d7ceba975e002af71378227c8b9b (patch)
treeec2ca63e241419f7c196dcf8d88e2402be3b9b46 /.local/bin/powercmd
parentup (diff)
downloaddotfiles-bsd-22ba7c46f959d7ceba975e002af71378227c8b9b.tar.gz
dotfiles-bsd-22ba7c46f959d7ceba975e002af71378227c8b9b.tar.bz2
dotfiles-bsd-22ba7c46f959d7ceba975e002af71378227c8b9b.tar.xz
dotfiles-bsd-22ba7c46f959d7ceba975e002af71378227c8b9b.tar.zst
dotfiles-bsd-22ba7c46f959d7ceba975e002af71378227c8b9b.zip
up
Diffstat (limited to '.local/bin/powercmd')
-rwxr-xr-x.local/bin/powercmd52
1 files changed, 46 insertions, 6 deletions
diff --git a/.local/bin/powercmd b/.local/bin/powercmd
index fadf6a0..7cb2ead 100755
--- a/.local/bin/powercmd
+++ b/.local/bin/powercmd
@@ -1,12 +1,13 @@
#!/bin/sh
-# [ -z "$1" ] && echo "no arg" && exit 1
+[ -z "$1" ] && echo "no arg" && exit 1
os="$(uname)"
-if [ $os -eq "Linux" ]; then
+if [ "$os" = "Linux" ]; then
grep "Artix" /etc/issue >/dev/null 2>&1 && os=1 || os=2
-elif [ $os -eq "FreeBSD" ]; then
+elif [ "$os" = "FreeBSD" ]; then
+ os=3
else
echo "unknown OS"
exit 1
@@ -17,7 +18,46 @@ fi
# 3: FreeBSD
case $os in
- 1) icon="" ;;
- 2) icon="" ;;
- 3) icon="" ;;
+ 1) icon=" " ;;
+ 2) icon=" " ;;
+ 3) icon=" " ;;
+esac
+
+case $1 in
+ "lock") xscreensaver-command -lock ;;
+ "sleep")
+ notify-send -u normal "sleep" "$icon G'night, partner!"
+ sleep 1
+ xscreensaver-command -lock
+ sleep 5
+ case $os in
+ 1) loginctl hibernate ;;
+ 2) systemctl hibernate ;;
+ 3) acpiconf -s 4 ;;
+ 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 ;;
+ 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 ;;
+ esac
+ ;;
+ *)
+ echo "wrong arg"
+ exit 1
+ ;;
esac