koekeishiya / yabai

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

Rule to send window to left or right #2301

Open rmgpinto opened 1 month ago

rmgpinto commented 1 month ago

I have a space with Mail (left window) and Calendar (right window) open. When I logout and tick Reopen windows when logging in sometimes the positions are swapped. Is there a way for yabai to put always Mail on the left and always Calendar on the right?

rmgpinto commented 1 month ago

Tried this on yabairc but it doesn't work:

FIRST_WINDOW_ID=$(yabai -m query --spaces --space 4 | jq '."first-window"')
FIRST_WINDOW_NAME=$(yabai -m query --windows --window ${FIRST_WINDOW_ID} | jq -r '.app')
if [ "$FIRST_WINDOW_NAME" != "Mail" ]; then
  yabai -m window ${FIRST_WINDOW_ID} --swap east
  yabai -m space 1 --focus
fi
Bellavene commented 1 month ago

Sadly, yabai does not have a master layout. I am asking about it for two years. Someone made even a PR for it two years ago, with the needed code, still no luck. And scripting first/last window is highly unreliably as it is now.

But thanks! I just realized, by your script, that we have actually a window order when querying spaces! Was trying to script it with other methods. Update: which does not work reliably : )