mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
28 lines
972 B
Bash
Executable File
28 lines
972 B
Bash
Executable File
#!/bin/sh
|
|
|
|
# A dmenu wrapper script for system functions.
|
|
|
|
# For non-systemd init systems.
|
|
case "$(readlink -f /sbin/init)" in
|
|
*runit*) hib="sudo -A zzz" ;;
|
|
*openrc*) reb="sudo -A openrc-shutdown -r"; shut="sudo -A openrc-shutdown -p" ;;
|
|
esac
|
|
|
|
pidof i3 && renew="i3 restart" && leave="i3 exit" && wm="i3"
|
|
pidof dwm && renew="kill -HUP $(pidof -s dwm)" && leave="kill -TERM $(pidof -s dwm)" && wm="dwm"
|
|
pidof bspwm && renew="${XDG_CONFIG_HOME:-$HOME/.config}/bspwm/bspwmrc" && wm="bspwm"
|
|
|
|
cmds="\
|
|
🔒 lock slock
|
|
🚪 leave ${wm:-Xorg} ${leave:-killall Xorg}
|
|
🐻 hibernate ${hib:-sudo -A systemctl suspend-then-hibernate}
|
|
🔃 reboot ${reb:-sudo -A reboot}
|
|
🖥 shutdown ${shut:-sudo -A shutdown -h now}"
|
|
|
|
# If both wm and renew command are known add it to the menu
|
|
[ -n "$wm" ] && [ -n "$renew" ] && cmds="$(echo "$cmds" | sed "3i♻ renew $wm $renew")"
|
|
|
|
choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1
|
|
|
|
`echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-`
|