koekeishiya / yabai

A tiling window manager for macOS based on binary space partitioning
MIT License
23.08k stars 638 forks source link

Yabai window specific rules not working consistently #1504

Open jgenunez opened 1 year ago

jgenunez commented 1 year ago

The configured rules targetting specific windows do not put the window in the correct space. Sometimes I have to restart Yabai or my machine and then it starts working again.

It appears some windows have a different title on application startup so the rules don't match. For example, the window titles for the zoom.us application are: 1) Zoom 2) Zoom 3) Zoom meeting

My rules are correctly targeting these with regular expressions but during startup, the windows get a different title for a second or two before they settle to the titles mentioned above. I only see this behavior with the zoom application.

Most chrome windows go to the correct space, but at least one goes to the wrong space. I renamed the windows using the window option in the menu bar. Chrome is the only application that allows me to name windows directly but it still has issues. It is also the only application that starts lagging significantly when combined with Yabai. It can't handle popping a tab out from a window without freezing for a few seconds.

Visual Studio Code can restore one window to the correct space all the time but the other window fails most of the time. These windows allow me to control the title using the settings page in VS code where I can set a formula for the titles. I make sure the formula always outputs the same name.

Here is how my display and spaces are defined: -Display1: space 1, space 2, space 3, space 4 -Display2: space 5, space 6, space 7, space 8 -Display3: space 9, space 10, space 11, space 12

Here what my yabairc look like:

`yabai -m config mouse_follows_focus on yabai -m config focus_follows_mouse off yabai -m config window_placement second_child yabai -m config window_topmost off yabai -m config window_opacity off yabai -m config window_opacity_duration 0.0 yabai -m config window_shadow off yabai -m config window_border off yabai -m config window_border_width 4

yabai -m config active_window_opacity 1.0 yabai -m config normal_window_opacity 0.90 yabai -m config split_ratio 0.50 yabai -m config auto_balance off yabai -m config mouse_modifier fn yabai -m config mouse_action1 move yabai -m config mouse_action2 resize

yabai -m config layout bsp

yabai -m space 9 --layout stack yabai -m space 10 --layout stack yabai -m space 11 --layout stack yabai -m space 12 --layout stack yabai -m space 6 --layout stack

yabai -m rule --add app="^System Preferences$" manage=off yabai -m rule --add app="^Activity Monitor$" manage=off yabai -m rule --add app="^Numi$" manage=off yabai -m rule --add app="^belenaEtcher$" manage=off yabai -m rule --add app="^Synology Drive Client$" manage=off yabai -m rule --add app="^OpenVPN Connect$" manage=off yabai -m rule --add app="^Grammarly Desktop$" manage=off

Space 1

yabai -m rule --add app="^Google Chrome$" title="master" space=1 yabai -m rule --add app="^Google Chrome$" title="media" space=9 yabai -m rule --add app="^iTerm2$" title="Master" space=5 yabai -m rule --add app="^Code$" title="juange" space=5

Space 2

yabai -m rule --add app="^Google Chrome$" title="ws" space=2 yabai -m rule --add app="^zoom.us$" title="Zoom" space=10 yabai -m rule --add app="^Numi$" space=10 yabai -m rule --add app="^Sourcetree$" title="Sourcetree" space=10 yabai -m rule --add app="^Postman$" space=2 yabai -m rule --add app="^Slack$" space=6 yabai -m rule --add app="^Microsoft Outlook$" space=6 yabai -m rule --add app="^Finder$" space=6 yabai -m rule --add app="^Excel$" space=6 yabai -m rule --add app="^zoom.us$" title="Zoom Meeting.*" space=6

Space 3

yabai -m rule --add app="^Google Chrome$" title="script" space=3 yabai -m rule --add app="^Script Editor$" space=7 yabai -m rule --add app="^Alfred Preferences$" space=11 yabai -m rule --add app="^Sublime Text$" space=3

Space 4

yabai -m rule --add app="^Google Chrome$" title="code" space=12 yabai -m rule --add app="^Code$" title="^ws.$" space=4 yabai -m rule --add app="^iMovie$" space=4 yabai -m rule --add app="^Meld" space=12 yabai -m rule --add app="^Sourcetree" title=".(Git)" space=8 yabai -m rule --add app="^iTerm2$" title="^Code.*$" space=8`

I few other things I forgot to mention:

Space 6 loses its stack layout configuration after some use. Especially after waking up from sleep state while space 5 gets its configuration somehow. So space 6 becomes a BSP layout and space 5 a stack layout.

After waking up from sleep some windows appear in space 1 despite having a rule set to a different space.

I tried building from source but somehow could not handle codesigning correctly so I kept getting the accessibility prompt indefinitely. I followed the instructions on the wiki to no avail.

For now, I uninstalled Yabai because it had too many disruptions to my daily workflow. After waking up from sleep, it usually becomes unstable, and the yabai.rc configuration appears to change on its own or does not work at all.

zxcvbn97 commented 1 year ago

Having the same issue.

zxcvbn97 commented 1 year ago

Any update to this issue?

thinhbg2812-2 commented 7 months ago

any update guys

koekeishiya commented 5 months ago

These are all quirks that happen because of the way macOS works, and it is not actually a bug in yabai functionality implementation.

I don't know how to deal with the case where some applications decide to change title late during startup. We don't/can't run rules all the time as windows regularly change title mid-lifetime, and this should not trigger rules for obvious reasons (e.g webbrowsers, terminal, file browser applications change title all the time).

The best I can suggest is to use a window_created signal with a filter for these specific applications, that runs your rules once after sleeping for x amount of milliseconds, depending on the application.

The space issue you are experiencing is also caused by macOS reordering/moving spaces between displays when a display goes to sleep/disconnect, and moves them back when they reconnect/wake up.

The "best" way for yabai to handle this is to simply let macOS do its thing, and you as a user need to be aware of what macOS is doing and try to workaround it in your workflow.

There is no easy fix for yabai to do here. If it was easy, it would have already been done/automated. If you think it is easy, feel free to create and submit a (obviously tested) PR.

danielo515 commented 1 month ago

What will be a way to run the rules on window creation? or even delayed?

faali1 commented 1 week ago

In theory, after all the other apps are loaded, you should be able to restart yabai and have it re-run the rules no? If so, that behavior does not work as well in my experience.