mirror of https://gitlab.com/dabruh/dotfiles.git
35 lines
637 B
Plaintext
35 lines
637 B
Plaintext
|
#!/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
|