dotfiles/sway/sway_exit.sh

26 lines
527 B
Bash
Raw Normal View History

2022-10-03 18:47:08 -06:00
#!/usr/bin/env bash
# Prompts for confirmation. 3 consecutive calls force exit without confirmation
declare -r CNT_FILE=~/.config/sway/sway_exit_counter
declare -ri MAX_COUNT=3
if [[ -e "$CNT_FILE" ]]; then
declare -i count="$(cat "$CNT_FILE")"
else
declare -i count=0
fi
(( count++ ))
if [[ $count -ge $MAX_COUNT ]]; then
swaymsg exit
else
echo "$count" > "$CNT_FILE"
swaynag -t warning \
-m 'Are you sure you want to exit sway?' \
-Z 'Yes, exit sway' \
2022-10-03 19:02:43 -06:00
"swaymsg exit"
2022-10-03 18:47:08 -06:00
fi
2022-10-03 19:02:43 -06:00
rm "$CNT_FILE" &>/dev/null