Created
December 25, 2018 04:43
-
-
Save vilhalmer/d192d081ec81ff9ae61c4fed5e40b052 to your computer and use it in GitHub Desktop.
Select sway containers by index
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
#!/usr/bin/env bash | |
# Bless jq, it even does the math for us | |
swaymsg "[con_id=$(swaymsg -t get_tree | jq "recurse(.nodes[]; .nodes) | .nodes | select(any(.focused)) | .[$1-1].id")]" focus |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
bindsym $mod+1 exec sway-focus-container-index 1
, etc and it's really handy for hopping around tabbed containers. As a bonus, $mod+0 will hop to the rightmost container since it causes jq to index into the array at -1.