Last active
January 20, 2023 19:05
-
-
Save Nervengift/0ab9e6127ac17b8317ac to your computer and use it in GitHub Desktop.
focus next window in i3 (like Alt+Tab in other WMs)
This file contains 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 | |
# ================================================================================== # | |
# Focus the next window on the current workspace in i3, e.g. for binding to Alt+Tab # | |
# Depends: jq, awk, i3wm (obviously) # | |
# Author: Nervengift <[email protected]> # | |
# License: Don't think this deserves a license, Public Domain # | |
# Known bugs: doesn't work with non-window container focused # | |
# ================================================================================== # | |
ws=$(i3-msg -t get_workspaces|jq "map(select(.focused))[]|.name") | |
windows=$(i3-msg -t get_tree|jq ".nodes|map(.nodes[])|map(.nodes[])|map(select(.type==\"workspace\" and .name==$ws))[0].nodes|map(recurse(.nodes[]))|map(.window)|.[]|values") | |
current=$(i3-msg -t get_tree|jq "recurse(.nodes[])|select(.focused)|.window") | |
if [ "x$current" != "xnull" ]; then | |
next=$(echo $windows | awk "BEGIN {RS=\" \";FS=\" \"};NR == 1 {w=\$1};{if (f == 1){w=\$1;f=0}else if (\$1 == \"$current\") f=1};END {print w}") | |
i3-msg "[id=$next]" focus > /dev/null | |
fi |
Changing line 15 to i3-msg "[id=$next]" focus > /dev/null
fixed it for me.
Jup, the change in line 15 did it for me as well :)
interesting.. it always worked for me this way...
I'll still incoporate the ""
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This doesnt seem to work.