dmenu-power (691B)
1 #!/bin/sh 2 ask() { 3 doas-askpass "$2" 4 #prompt="Do you really want to $1?" 5 #answer="$(printf 'Yes\nNo' | dmenu -i -p "$prompt")" 6 #[ "$answer" = "Yes" ] && doas-askpass "$2" 7 } 8 9 btn_power="⏻ Poweroff" 10 btn_reboot=" Reboot" 11 btn_logout=" Logout" 12 13 CHOICE="$(printf '%s\n' "$btn_logout" "$btn_reboot" "$btn_power" | dmenu -i -p "ﮣ Powermenu:")" 14 [ "$CHOICE" ] || exit 2 15 16 case "$CHOICE" in 17 #"$btn_logout") ask "logout from \"$(logname)\"" "pkill -KILL -u \"$(logname)\"" ;; 18 "$btn_logout") ask "logout from \"$(logname)\"" "kill -9 -1" ;; 19 "$btn_reboot") ask "reboot this machine" "reboot" ;; 20 "$btn_power") ask "this computer to shutdown" "poweroff";; 21 esac