29 lines
556 B
Bash
Executable file
29 lines
556 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
TIMES=0
|
|
|
|
run_root() {
|
|
TIMES=$((TIMES + 1))
|
|
st -e "${__BASH_RUNAS:-sudo}" "$@" || ([ "$TIMES" -lt 3 ] && run_root "$@")
|
|
}
|
|
|
|
main() {
|
|
options=("1 Cancel"
|
|
"2 Quit DWM"
|
|
"3 Reboot"
|
|
"4 Poweroff / Shutdown")
|
|
|
|
option="$(printf "%s\n" "${options[@]}" | dmenu | awk '{ print $1 }')"
|
|
|
|
[[ ! $option ]] && exit 1
|
|
|
|
case "$option" in
|
|
1) exit 0 ;;
|
|
2) killall dwm ;;
|
|
3) run_root reboot -h ;;
|
|
4) run_root poweroff ;;
|
|
*) notify-send "Option '$option' not found" ;;
|
|
esac
|
|
}
|
|
|
|
main "$@"
|