-
-
Notifications
You must be signed in to change notification settings - Fork 655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to focus most recent window in a space after switching spaces #719
Comments
You can use the following signal(s):
No need to modify your focus binds. |
Thanks, that solved it! |
For anyone still running into this issue, I found that Microsoft Teams was usurping the 0 spot in the window array on space that it had been seen on (Great job, Microsoft.... :-( ) I tend to have a single space for most of my windows that is labeled with the name of the application that will be open on it, so I wrote a little helper function using the above so that whenever I switch to a space, it will focus the window that has the same name as the space. Hope this helps! focus_window () {
SPACE_NAME=$(yabai -m query --spaces --space | jq ".label")
WINDOW_ID=$(yabai -m query --windows --space | jq ".[] | select (.app=${SPACE_NAME}).id")
yabai -m window --focus "${WINDOW_ID}"
}
# focus window after active space changes
yabai -m signal --add event=space_changed action="focus_window"
# focus window after active display changes
yabai -m signal --add event=display_changed action="focus_window" |
@koekeishiya Thanks a lot.
I'll leave it here just in case it won't work for somebody as in my case. I had a floating MS Teams window and to make it work I changed it to |
Using a third-party tool, yabai -m signal --add event=space_changed action='yabai -m window --focus $(yabai -m query --windows --space | jq -r '\''[.[]|select(."is-visible")][0].id'\'')' |
After switching spaces I often have to manually focus a window in that space, which gets really annoying really quickly. Instead I'd like yabai to always focus the most recent window in the space I'm in. I tried the following commands in my skhdrc (here shown for spaces 1 and 2):
but those didn't seem to solve anything.
Btw, I have
When switching to an application, switch to a Space with open windows for the application
unchecked in System Preferences -> Mission Control.The text was updated successfully, but these errors were encountered: