yabai
yabai copied to clipboard
Reload yabai without restarting it
I noticed that if I attach/detach a monitor from my laptop, yabai
is not to moving the windows to their assigned space. The only way to achieve this is to restart yabai
after the display change event.
I guess this is because MacOS changes the space indexing after a display event or something like it.
I was wondering if there is a way to tell yabai to "reload" without restarting it. Ideally I would like to do something like this:
yabai -m signal --add event=display_added action="sleep5 && yabai --reload && do_a_bunch_of_other_things"
yabai -m signal --add event=display_removed action="sleep 5 && yabai --reload && do_a_bunch_of_other_things"
Is there a way to achieve something like this already? I have tried to fully restart yabai
inside the event action, but that cannot really work as the action is basically interrupted by the yabai restart and do_a_bunch_of_other_things
is never executed.
FYI I cannot enable the scripting addition on this system, maybe that already solves this issue.
I have something similar happen whenever my Mac Studio wakes from sleep. It has a Studio display as main and UHD secondary display attached.
I don't have a solution, instead as a workaround have an alias yrs
to yabai --restart-service
. 😅
Not sure what is meant by reload; which part of yabai logic is it that you are interested in triggering? I'd personally just write my config as a series of scripts in a way that would let me set up a given state on demand.
You can have general settings, signals and rules defined in separate files, that are all sourced from the main file. When you want do to a "reload" you can delete existing signals/rules and re-run the proper files etc.
Thanks for the detailed answer. I managed to reach my goal by making the script logic a bit more predictable.