Created
May 20, 2026 19:40
-
-
Save spuk-/f51bb2a47b915c0894412aee57d7407d to your computer and use it in GitHub Desktop.
Very simple "Alt-Tab" / MRU (Most Recently Used) switcher for sway, requiring only bash, jq and sway itself, no daemon running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Very simple "Alt-Tab" / MRU (Most Recently Used) switcher for sway, | |
| # requiring only bash, jq and sway itself, no daemon running. | |
| # | |
| # Copy it somewhere in $PATH and add to ~/.config/sway/config: | |
| # bindsym --no-repeat Mod1+tab exec sway-alttab.sh | |
| # | |
| # or run in a terminal: | |
| # swaymsg "bindsym --no-repeat Mod1+tab exec sway-alttab.sh" | |
| # The only possible argument is how many windows to skip (0-9): | |
| # 0=no switching, 1=previous (default), 2=next-previous, ... | |
| case "$1" in | |
| [0-9]) SKIP="$1" ;; | |
| *) SKIP="1" ;; | |
| esac | |
| CON_ID=`swaymsg -t get_tree | jq ".. | select(.type?==\"workspace\" and .nodes[]?.nodes[]?.focused?==true).nodes[].focus[$SKIP]"` | |
| swaymsg "[con_id=$CON_ID] focus" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment