sylvain durand

Yabai tiling window manager on macOS

A few years first under i3, then under sway, have definitely converted me to tiling window manager. The windows automatically occupy the whole screen, without overlapping, and can be created, moved and resized with a few keyboard shortcuts.

Back on macOS, finding these features was my first priority! Although not as fast as its Linux counterpart, Yabai, together with skhd for keyboard shortcuts, is perfect for this role.

Yabai

With Homebrew, Yabai is simply installed with:

brew install koekeishiya/formulae/yabai

To use advanced features, including space management, some macOS security tools must be disabled. I prefer not to do this, which is not a problem for simple use.

The default configuration file is located in ~/.config/yabai/yabairc. Here is for example the configuration I use:

# ~/.config/yabai/yabairc

# layout
yabai -m config layout                      bsp

# window gaps
yabai -m config top_padding                 0
yabai -m config bottom_padding              0
yabai -m config left_padding                0
yabai -m config right_padding               1
yabai -m config window_gap                  7

# applications
yabai -m rule --add app="^App Store$" manage=off
yabai -m rule --add app="^Messages$" manage=off

We start the service to take it into account:

brew services start yabai

skhd

In the same way, skhd is installed and started with:

brew install koekeishiya/formulae/skhd
brew services start skhd

The shortcuts are then configured in ~/.config/skhd/skhdrc.

As a vim user, i use more naturally h j k l instead of ← ↓ ↑ → to move. Associated with the ⌘ key, I change the focus of the windows. The combination ⌘ + ⇧ moves the windows, and ⌥ resizes them.

Finally, I use ⌘+⏎ to open a terminal, and ⌘+D to open the browser.

The relevant configuration is as follows:

# applications
cmd - return : /Applications/kitty.app/Contents/MacOS/kitty
cmd - d : /Applications/Firefox.app/Contents/MacOS/firefox

# focus window
cmd - h : yabai -m window --focus west
cmd - j : yabai -m window --focus south
cmd - l : yabai -m window --focus east
cmd - k : yabai -m window --focus north

# move window
cmd + shift - h : yabai -m window --warp west
cmd + shift - j : yabai -m window --warp south
cmd + shift - l : yabai -m window --warp east
cmd + shift - k : yabai -m window --warp north

# resize window
alt + shift - h : yabai -m window --resize left:-50:0; \
                  yabai -m window --resize right:-50:0
alt + shift - j : yabai -m window --resize bottom:0:50; \
                  yabai -m window --resize top:0:50
alt + shift - k : yabai -m window --resize top:0:-50; \
                  yabai -m window --resize bottom:0:-50
alt + shift - l : yabai -m window --resize right:50:0; \
                  yabai -m window --resize left:50:0

# fullscreen
shift + cmd - f : yabai -m window --toggle native-fullscreen

We finally start skhd:

brew services start skhd