yabai icon indicating copy to clipboard operation
yabai copied to clipboard

Reload yabai without restarting it

Open crisidev opened this issue 1 year ago • 1 comments

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.

crisidev avatar Nov 26 '23 11:11 crisidev

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. 😅

shrugalic avatar Dec 02 '23 15:12 shrugalic

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.

koekeishiya avatar Feb 19 '24 23:02 koekeishiya

Thanks for the detailed answer. I managed to reach my goal by making the script logic a bit more predictable.

crisidev avatar Mar 12 '24 10:03 crisidev