aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardofSprites <[email protected]>2025-01-08 17:54:23 -0500
committerBardofSprites <[email protected]>2025-01-08 17:54:23 -0500
commit2f95620630955d6bd526ded575ed1d377573fa85 (patch)
tree3d9541eec9b1a99c4bf62083626db402c508ad75
parent2fe17e4f002988a67ff263edb61df299f765814e (diff)
complete sysact script
-rwxr-xr-xbin/.local/bin/scripts/sysact30
-rwxr-xr-xbin/.local/bin/scripts/sysact.sh17
2 files changed, 30 insertions, 17 deletions
diff --git a/bin/.local/bin/scripts/sysact b/bin/.local/bin/scripts/sysact
new file mode 100755
index 0000000..f2badee
--- /dev/null
+++ b/bin/.local/bin/scripts/sysact
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# A dmenu wrapper script for system functions.
+export WM="dwm"
+case "$(readlink -f /sbin/init)" in
+ *systemd*) ctl='systemctl' ;;
+ *) ctl='loginctl' ;;
+esac
+
+wmpid(){ # This function is needed if there are multiple instances of the window manager.
+ tree="$(pstree -ps $$)"
+ tree="${tree#*$WM(}"
+ echo "${tree%%)*}"
+}
+
+confirm() {
+ case "$(printf "Yes\nNo" | dmenu -i -p 'Confirm: ')" in
+ 'Yes') $1 ;;
+ 'No') exit 1 ;;
+ *) exit 1 ;; # Handles invalid inputs.
+ esac
+}
+
+case "$(printf "๐Ÿ”’ lock\n๐Ÿ’ค sleep\n๐Ÿ”ƒ reboot\n๐Ÿ–ฅ๏ธ shutdown" | dmenu -i -p 'Action: ')" in
+ '๐Ÿ”’ lock') slock ;;
+ '๐Ÿ’ค sleep') confirm "$ctl suspend" ;;
+ '๐Ÿ”ƒ reboot') confirm "$ctl reboot" ;;
+ '๐Ÿ–ฅ๏ธ shutdown') confirm "$ctl poweroff" ;;
+ *) exit 1 ;; # Handles invalid inputs.
+esac
diff --git a/bin/.local/bin/scripts/sysact.sh b/bin/.local/bin/scripts/sysact.sh
deleted file mode 100755
index 4a7c191..0000000
--- a/bin/.local/bin/scripts/sysact.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-# A dmenu wrapper script for system functions.
-export WM="dwm"
-case "$(readlink -f /sbin/init)" in
- *systemd*) ctl='systemctl' ;;
- *) ctl='loginctl' ;;
-esac
-
-case "$(printf "๐Ÿ”’ lock\n๐Ÿป hibernate\n๐Ÿ”ƒ reboot\n๐Ÿงนshutdown\n๐Ÿ’ค sleep" | dmenu -i -p 'Action: ')" in
- '๐Ÿ”’ lock') slock ;;
- '๐Ÿป hibernate') slock $ctl hibernate -i ;;
- '๐Ÿ’ค sleep') slock $ctl suspend -i ;;
- '๐Ÿ”ƒ reboot') $ctl reboot -i ;;
- '๐Ÿ–ฅ๏ธshutdown') $ctl poweroff -i ;;
- *) exit 1 ;;
-esac