diff --git a/sway/config b/sway/config index 5a5b30d..6eb684d 100644 --- a/sway/config +++ b/sway/config @@ -294,8 +294,8 @@ exec sudo ~/.configs_pointer/bin/switch_keyboard.sh pc bindsym $mod1+i exec ~/.config/sway/toggle_fcitx.sh # Mako notifications exec mako - # Exit sway (logs you out of your Wayland session) -bindsym $mod2+Escape exec swaynag -t warning -m 'Are you sure you want to exit sway?' -b 'Yes, exit sway' 'swaymsg exit' + # Exit sway (hit 3 times repeatedly to force exit) +bindsym $mod2+Escape exec ~/.config/sway/sway_exit.sh # Screenshots ==== bindsym $mod2+6 mode "screenshots" diff --git a/sway/sway_exit.sh b/sway/sway_exit.sh new file mode 100755 index 0000000..3c5c762 --- /dev/null +++ b/sway/sway_exit.sh @@ -0,0 +1,25 @@ +#!/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' \ + "swaymsg exit; rm $CNT_FILE" +fi + +rm ~/.config/sway/sway_exit_counter &>/dev/null