2022-06-03 20:14:32 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-06-08 10:33:49 +02:00
|
|
|
# shellcheck disable=SC2086
|
2022-06-08 10:36:47 +02:00
|
|
|
DMENU_ARGS="-i -nb #e74c3c -nf #303030 -sb #c0392b -sf #ecf0f1"
|
2022-06-08 10:33:49 +02:00
|
|
|
|
2022-06-07 12:54:09 +02:00
|
|
|
COMMANDS="$(i3exit commands | sed 's/\,/\ /g' | sed 's/.*/\L&/; s/[a-z]*/\u&/g')"
|
2022-06-08 10:36:47 +02:00
|
|
|
ACTION="$(xargs -n 1 <<<"$COMMANDS" | dmenu $DMENU_ARGS -p "exitctl")"
|
2022-06-03 20:14:32 +02:00
|
|
|
[ -z "$ACTION" ] && exit 1
|
|
|
|
echo "INFO: Selected action $ACTION."
|
|
|
|
|
2022-06-08 10:36:47 +02:00
|
|
|
CONFIRMATION="$(xargs -n 1 <<<"No Yes" | dmenu $DMENU_ARGS -p "Are you sure you want to ${ACTION,,}?")"
|
2022-06-03 20:14:32 +02:00
|
|
|
{ [ -z "$CONFIRMATION" ] || [[ "$CONFIRMATION" != "Yes" ]]; } && exit 1
|
|
|
|
|
|
|
|
echo "INFO: Action confirmed."
|
|
|
|
|
2022-06-07 12:54:09 +02:00
|
|
|
if ! i3exit "${ACTION,,}"; then
|
2022-06-03 20:14:32 +02:00
|
|
|
echo "ERROR: Invalid action '${ACTION,,}'." 1>&2
|
2022-06-07 12:54:09 +02:00
|
|
|
exit 2
|
|
|
|
fi
|