Hello,
I just got an ultra wide monitor, and was wondering if Yabai has the option to manage a layout of 3 columns, since for the aspect ratio is ideal, or event the option to create several columns. And if it's not enabled, how could I enable it or add code for it?
Thanks.
Would also like to know if this is possible. It would be especially nice to have a "priority" window that is larger than the two windows on either side.
To decide how a node is split, use _yabai -m window --insert .._
To change a split after it has already been created, use _yabai -m window --toggle split_
OR
Drag a window and drop it inside the edge of some other window by using the mouse
To make all nodes occupy the same amout of area, use _yabai -m space --balance_
You can automate this process by combining signals and queries.
All of this is mentioned (and inferred) in the documentation/wiki
That works to get three evenly sized windows, however, it doesn't work for making one of the windows larger than the others.
I think this is going to be an issue with #180 and #643. If my understanding of resize is correct, I should be able to set the focused window (in this case the middle window) to an absolute width, which would then automatically set the other windows to fit. However, I am getting the error mentioned in #643 when trying to use the resize command.
Running yabai -m window --resize abs:1280:1417 on the left-most window in the space:
"frame":{
"x":0.0000,
"y":23.0000,
"w":1707.0000,
"h":1417.0000
}

I would expect this command to work because it shouldn't need to find a node to set an absolute width of the left-most monitor if my understanding of the error message is correct anyways.
If you are unable to resize a window in the middle of the tree, then the next best solution would be to set the split ratio for each visible window, which as mentioned in #180 is difficult to do.
Running yabai -m window --resize abs:1280:1417 on the left-most window in the space
I would expect this command to work because it shouldn't need to find a node to set an absolute width of the left-most monitor if my understanding of the error message is correct anyways.
That error message is just garbage. Absolute resizing only works for floating windows, the same as the grid command. Opened issue #661 to track that.
You'd have to use relative resizing to expand the middle window in both directions:
yabai -m window --resize left:-20:0 && yabai -m window --resize right:20:0
Ah, absolute values only working for floating windows makes sense. Maybe this line should be updated to reflect that.
https://github.com/koekeishiya/yabai/blob/7406ce51837f3674f19d40dad7e75974c3054200/doc/yabai.1#L413
I guess my other question would be if it's possible to define a layout using floating windows? It likely would not be ideal though.
Maybe this line should be updated to reflect that.
Noted in the created issue, thanks.
I guess my other question would be if it's possible to define a layout using floating windows? It likely would not be ideal though.
So, the grid and abs commands in general was implemented so that I would not have to use spectacle/shiftit/hammerspoon or w/e for such simple functionality.
I have not tried to make custom layouts, but I think it would be possible using signals and queries. For example let's say you configure space 3 to be floating. Then you can hook a script up to the window_created signal, query the current space and check if it is floating, query information about the newly created window and check its title/app to decide whatever dimensions you want to assign it. Probably not the most efficient thing in the world, it was never really intended to be used like this.
Yea, that's fair, it's kind of an odd use-case.
Trying out the example command, and it seems to be opperating funny.
For context, my monitor is 5120 pixels wide. I want the middle monitor to be 2560 pixels wide.
Setting the space to balanced results in each of the three windows being 1707px wide, therefore I would need to increase the size of the middle monitor by 426.5 pixels in each direction to get 2560.
1707 + (426.5*2) = 2560
When I run alt - r : yabai -m window --resize left:-426.5:0 && yabai -m window --resize right:426.5:0 I end up with the left-most window being 1280px wide (correct), the middle window being 2346px wide (incorrect), and the right-most window being 1493px wide (incorrect). There is about 200 pixel difference between the result and the expected outcome, and I'm not sure where that is happening.
Running alt - r : yabai -m window 12744 --resize left:-426.5:0 && yabai -m window 12744 --resize right:426.5:0 results in the same, 12744 being the ID of the middle window. I suspect this might be a bug?
I don't use this very frequently, but it does seem to work fine with my hardware. The code responsible for translating coordinates to ratio is here: https://github.com/koekeishiya/yabai/blob/master/src/window_manager.c#L379 and 384 if you want to try and investigate further.
Just to clarify, are these values absolute when using the right/left syntax, or percentages?
I don't know C at all unfortunately.
It is nice to see such fast and kind responses from both the creator a really active member. Thanks for your time. And well, since all the code is in C... I am wondering, would't it be possible to define layouts the way dwm does? Or even further... import dwm code for the layouts? This way we could have different modes for yabai, a column mode, bsp mode, and leave the possibility for even more growth, we could even borrow the status bar. Not sure if this is far fetched, but is just an idea.
Just to clarify, I am wondering if it is possible to create a priority window layout like FancyZones (https://github.com/microsoft/PowerToys/wiki/FancyZones-Overview), in which a monitor in the middle of the display is (generally) larger and windows can be tiled off to the sides.

https://github.com/microsoft/PowerToys/wiki/FancyZones-Overview
The screenshot of layouts in the link above only shows 3 windows, but if you were to set it to 4 windows, you would get a horizontal split either on the left or right side of the priority window, and 5 would add another split on the opposite side, and so on as you add more splits.
This is an ideal setup for ultrawide monitors, or when you want to focus on one task but still have utility windows (chat/music) open to the side.
I've tried using the ratio and resize commands, however, these always end up with the priority window not centred or require a lot of shortcut presses to get an approximation of the center.
I've also tried this, and although it looks like it should work, it doesn't seem to actually evenly resize the window.
:: default : yabai -m config window_border off
:: resize @ : yabai -m config window_border on
alt - r ; resize
resize < escape ; default
resize < return ; default
resize < h : yabai -m window --resize left:100:0 ; yabai -m window --resize right:-100:0
resize < l : yabai -m window --resize left:-100:0 ; yabai -m window --resize right:100:0
resize < j : yabai -m window --resize top:0:-100 ; yabai -m window --resize bottom:0:100
resize < k : yabai -m window --resize top:0:100 ; yabai -m window --resize bottom:0:-100
This might be better off for a new issue? I think the original issue was about getting windows into three columns, which is possible by toggling the split option.
I think this is going to be an issue with #180 and #643. If my understanding of
resizeis correct, I should be able to set the focused window (in this case the middle window) to an absolute width, which would then automatically set the other windows to fit. However, I am getting the error mentioned in #643 when trying to use the resize command.
I'm tracking this issue as I'm debating between replacing my 24" 4k monitor with a 16:9 27" 5k or a 5k ultrawide, but I haven't parsed this whole thread yet. However, #643 was user error on my part 馃憥 and can be ignored.
This might be better off for a new issue? I think the original issue was about getting windows into three columns, which is possible by toggling the split option.
Actually there is no problem, the issue can continue active with the new topic, if you are all confortable with it I can rename the issue into the addition of a more flexible layout option.
As a side note, the ability to create placeholder entities would be nice, then you could use something like i3-layout-manager to build your preferred layout even if you don't open all the windows right away.
Would solve some issues with wanting a priority window with only 1-2 windows open.
Actually yes. I was suggesting the usage of dwm-like patches for adding or creating layouts since it is also written in C, and also would avoid having to store and load different sessions, and with just a keybinding we switch through the different layouts we added.
Looking at DWM (I鈥檝e not used it before), but this patch is what I鈥檓 looking for. https://dwm.suckless.org/patches/centeredmaster/
I can do centeredfloatingmaster by setting a floating window to center:
alt - t : yabai -m window --toggle float;\
yabai -m window --grid 4:4:1:0:2:4
Which is pretty nice.
While technically there is no reason why you could not create something that would support multiple layouts as described above - this would not be a good fit for yabai due to the way it is designed (on purpose) to be bsp-only. You cannot just simply add layout logic without having to also reimplement basically all windowing operations that currently exist, because all the existing ones do is navigate and manipulate the bsp-tree.
I understand why such layouts are popular and the need for them, but that does unfortunately not align with the goals that I have. IIRC the design of Amethyst is a better fit towards that goal.
The difficult part of writing window managers for macOS is retrieving and managing OS state, which I think yabai does in a very robust way, and so I would rather encourage someone to build on the core of yabai and just write their own layout system from scratch. If someone is interested in doing so I would be more than happy to answer questions regarding the codebase and its structure.
Maybe I'm miss-understanding, but since the bsp-tree seems to support window resizing, could the "layout" system not be just resizing the windows the same way each time, while maintaining the bsp-tree, instead of floating?
I see some drawbacks to this, mainly it not working on spaces with fewer windows than the resize is expecting, and the need for a lot of querying in order to do it properly, however, I have seen some of the commands/scripts that people come up with for window management and it seems like it may be possible. I know you had mentioned doing this with floating windows, but I suspect it could be done with managed windows as well.
I still suspect there is something funky going on with the resize commands though, as I've tried both of the below commands.
yabai -m window --resize left:-100:0 ; yabai -m window --resize right:100:0
yabai -m window --resize left:-20:0 && yabai -m window --resize right:20:0
I'm not sure if this is because a window is refusing to resize any smaller, or (more likely) an issue with using ratios for the window resizing. Is there a reason that windows are resized using a ratio in the bsp-tree? Window size seems to be based on pixel count, so could you not increase/decrease height/width by pixel count rather than a ratio?
Note: running yabai -m window --resize left:-20:0 && yabai -m window --resize right:20:0 once results in a balanced window layout (3 windows at 1707px wide) changing to windows that are (from left to right) 1697, 1737, and 1687 px wide.
Running yabai -m window --resize left:20:0 && yabai -m window --resize right:-20:0 once results in a balanced window layout changing to (left to right) 1717, 1677, and 1727 px wide.
It seems like the resize left command is dividing the resize value in half. I think that maybe a bug.
I suspect this is due to using ratios for the resizing, I can get right:20/left:-30 working evenly for a few commands, but then it gets out of sync again after more than 5-6 runs.
The difficult part of writing window managers for macOS is retrieving and managing OS state, which I think yabai does in a very robust way, and so I would rather encourage someone to build on the core of yabai and just write their own layout system from scratch. If someone is interested in doing so I would be more than happy to answer questions regarding the codebase and its structure.
Well that is completely understandable, and in fact I do believe yabai is quite robust as you mention. Perhaps it could be posible to create some sort of implementation of i3 o dwm over the core of yabai? I'm not so proficient in C, I've taken the path of web and app development, but I could help a bit with tying to make this addition. I reckon it would be quite the blast to have a dwm like tiling window manager built over yabai for Mac OS, and perhaps draw even more users to it.
Most helpful comment
Looking at DWM (I鈥檝e not used it before), but this patch is what I鈥檓 looking for. https://dwm.suckless.org/patches/centeredmaster/
I can do
centeredfloatingmasterby setting a floating window to center:Which is pretty nice.