i3/sway script to toggle between last windows. For older Python version (<3.7), use this branch.
pip install --upgrade i3-swap-focus
exec i3-swap-focus
bindsym $mod+Tab exec pkill -USR1 -F "${XDG_RUNTIME_DIR}/swap_focus.pid"
To ignore some windows (e.g windows that belong to scratchpad), just mark them with ignore_focus
in your config :
# Put a term in scratchpad
exec alacritty --class scratchpad_term
# i3 :
for_window [instance="scratchpad_term"] mark "ignore_focus", move scratchpad
# sway :
for_window [app_id="scratchpad_term"] mark "ignore_focus", move scratchpad
This script accepts a --stay-in-workspace
flag if you do not wish to focus on a different workspace :
exec i3-swap-focus --stay-in-workspace