dotfiles/.local/bin/dmenuexit

17 lines
516 B
Plaintext
Raw Normal View History

2022-06-03 20:14:32 +02:00
#!/bin/bash
COMMANDS="$(i3exit commands | sed 's/\,/\ /g' | sed 's/.*/\L&/; s/[a-z]*/\u&/g')"
ACTION="$(xargs -n 1 <<<"$COMMANDS" | 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."
if ! i3exit "${ACTION,,}"; then
2022-06-03 20:14:32 +02:00
echo "ERROR: Invalid action '${ACTION,,}'." 1>&2
exit 2
fi