2022-06-03 20:14:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-06-07 12:42:21 +02:00
|
|
|
ACTION="$(xargs -n 1 <<<"Lock Suspend Hibernate Logout Shutdown Reboot" | dmenu -i -p "exitctl")"
|
2022-06-03 20:14:32 +02:00
|
|
|
[ -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
|
|
|
|
;;
|
2022-06-07 12:42:21 +02:00
|
|
|
logout)
|
2022-06-03 20:14:32 +02:00
|
|
|
i3-msg exit
|
|
|
|
;;
|
|
|
|
shutdown)
|
|
|
|
poweroff
|
|
|
|
;;
|
|
|
|
reboot)
|
|
|
|
reboot
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "ERROR: Invalid action '${ACTION,,}'." 1>&2
|
|
|
|
;;
|
|
|
|
esac
|