diff options
| author | BardofSprites <[email protected]> | 2025-01-08 17:54:23 -0500 |
|---|---|---|
| committer | BardofSprites <[email protected]> | 2025-01-08 17:54:23 -0500 |
| commit | 2f95620630955d6bd526ded575ed1d377573fa85 (patch) | |
| tree | 3d9541eec9b1a99c4bf62083626db402c508ad75 /bin | |
| parent | 2fe17e4f002988a67ff263edb61df299f765814e (diff) | |
complete sysact script
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/.local/bin/scripts/sysact | 30 | ||||
| -rwxr-xr-x | bin/.local/bin/scripts/sysact.sh | 17 |
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 |
