Yabai: Resize window like i3 but not saparate command.

Created on 3 Jun 2019  路  5Comments  路  Source: koekeishiya/yabai

I've browsing around to find a solution but failed, seems like yabai need to have separate command to shrink/extend windows size?

when I'm using chunkwm I have config like this one.

# change windows size
# shrink/extend width/height                                        # -/+                                                                         # -/+
resize < h : chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge east
resize < j : chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge north; chunkc tiling::window --use-temporary-ratio -0.05 --adjust-window-edge south
resize < k : chunkc tiling::window --use-temporary-ratio  0.05 --adjust-window-edge north; chunkc tiling::window --use-temporary-ratio  0.05 --adjust-window-edge south
resize < l : chunkc tiling::window --use-temporary-ratio  0.05 --adjust-window-edge west;  chunkc tiling::window --use-temporary-ratio  0.05 --adjust-window-edge east

but it seems to can't not be done with yabai's method, so I currently made two mods for shrink/extend.

# increase window size
big < h : yabai -m window --resize left:-20:0
big < j : yabai -m window --resize bottom:0:20
big < k : yabai -m window --resize top:0:-20
big < l : yabai -m window --resize right:20:0

# decrease window size
small < h : yabai -m window --resize left:20:0
small < j : yabai -m window --resize bottom:0:-20
small < k : yabai -m window --resize top:0:20
small < l : yabai -m window --resize right:-20:0

I've tried to use same method on yabai, but can't perform same result as chunkwm does.
Is there any other method I'm not aware of to do shrink/extend in one key bind?
thanks for any support.

Most helpful comment

big < h : yabai -m window --resize left:-20:0 ; yabai -m window --resize right:-20:0
big < j : yabai -m window --resize bottom:0:20 ; yabai -m window --resize top:0:20
big < k : yabai -m window --resize top:0:-20 ; yabai -m window --resize bottom:0:-20 
big < l : yabai -m window --resize right:20:0 ; yabai -m window --resize left:-20:0
#                                                                             ^^^
#                                                    Should be 20 instead of -20?

All 5 comments

Your chunkwm setup did two calls for every keybinding, why not do the same for yabai?

resize < h : yabai -m window --resize left:-20:0; yabai -m window --resize right:-20:0
# [...]

actually I did...

# increase window size
big < h : yabai -m window --resize left:-20:0 ; yabai -m window --resize right:-20:0
big < j : yabai -m window --resize bottom:0:20 ; yabai -m window --resize top:0:20
big < k : yabai -m window --resize top:0:-20 ; yabai -m window --resize bottom:0:-20
big < l : yabai -m window --resize right:20:0 ; yabai -m window --resize left:-20:0

when the window is on right, both h or l will increase the window size

big < h : yabai -m window --resize left:-20:0 ; yabai -m window --resize right:-20:0
big < j : yabai -m window --resize bottom:0:20 ; yabai -m window --resize top:0:20
big < k : yabai -m window --resize top:0:-20 ; yabai -m window --resize bottom:0:-20 
big < l : yabai -m window --resize right:20:0 ; yabai -m window --resize left:-20:0
#                                                                             ^^^
#                                                    Should be 20 instead of -20?

ah... didn't see that typo, this solved my issue,
Thank you! closing this.

The above solution only seem to work for windows that are touching the edge of the display. Windows in the middle of the layout are moved rather than resized.

To my knowledge, in i3's resize mode H decreases window width rather than trying to resize such that the window is further left. Similarly, L increases window width. When a window is in the middle of the layout, it shrinks or expands in both directions.

This skhd snippet implements this behavior, using window borders to indicate resize mode:

:: 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
Was this page helpful?
0 / 5 - 0 ratings