Files
dotfiles/.local/bin/sysact

23 lines
583 B
Plaintext
Raw Normal View History

2021-04-11 17:21:20 +01:00
#!/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 0" ;;
esac
2021-05-16 12:43:18 +01:00
2021-04-11 17:21:20 +01:00
cmds="\
2021-05-16 12:43:18 +01:00
 lock slock
 leave dwm dwmc quit
 renew dwm dwmc restart
 hibernate slock ${hib:-systemctl suspend-then-hibernate -i}
 reboot ${reb:-sudo -A reboot}
 shutdown ${shut:-sudo -A shutdown -h now}"
2021-04-11 17:21:20 +01:00
choice="$(echo "$cmds" | cut -d' ' -f 1 | dmenu)" || exit 1
`echo "$cmds" | grep "^$choice " | cut -d ' ' -f2-`