dotfiles/.local/bin/dmenuexit

35 lines
637 B
Plaintext
Raw Normal View History

2022-06-03 20:14:32 +02:00
#!/bin/bash
ACTION="$(xargs -n 1 <<<"Lock Suspend Hibernate 'Exit i3' Shutdown Reboot" | dmenu -i -p "exitctl")"
[ -z "$ACTION" ] && exit 1
echo "INFO: Selected action $ACTION."
CONFIRMATION="$(xargs -n 1 <<<"No Yes" | dmenu -i -p "Are you sure you want to ${ACTION,,}?")"
{ [ -z "$CONFIRMATION" ] || [[ "$CONFIRMATION" != "Yes" ]]; } && exit 1
echo "INFO: Action confirmed."
case "${ACTION,,}" in
lock)
loginctl lock-session
;;
suspend)
systemctl suspend
;;
hibernate)
systemctl hibernate
;;
'exit i3')
i3-msg exit
;;
shutdown)
poweroff
;;
reboot)
reboot
;;
*)
echo "ERROR: Invalid action '${ACTION,,}'." 1>&2
;;
esac