Your Windows on Autopilot

04 Jul 2024 . tech . Comments
#productivity

Have you thought how much time you spend managing your windows? Each time you open a new window you have to decide where to place it and then move it or resize it. We do it so often that we take it for granted, but what if we could offload this task to the window manager?

Window managers that open windows in non overlapping tiles were first introduced in 1981 by Xerox, but they have become more popular recently. The idea is simple, when you open a new window, the window manager will automatically size and place it in the right position for you, without having it overlap with the other open windows of your space. And the “right position” can be configured in order to match your workflow and preferences.

There are plenty of tiling window managers for each OS, but more or less they offer the same core features for managing the windows. The most popular window placement strategy is the Binary Space Partitioning, which will halve the space each time a new window is added, like this:

wiki From Wikipedia

Opening more than three windows in a workspace in this placement strategy is not very practical, so in practice you should expect something like this:

bsp

There will be times that you’ll want to manipulate the open windows, so here are a few features of the window manager that can will be useful:

  1. Rotating the windows on the X and Y axes: axis-rotate

  2. Maximizing the current window, in order to focus on a single task, or to present a window in a meeting: fullscreen

  3. Rotating the windows in case you want to bring another window on the left half of the screen: rotate

  4. Changing focus between the windows of the workspace: focus

  5. Last, not a fancy feature but a very practical, is excluding windows from the
    tiling placement, which is convenient for your utility windows that you want them to float above the tiled windows: float

If you are a macOS user and want to give it a try, you can install yabai and skhd (for setting up the window manipulation shortcuts) using brew:

brew install koekeishiya/formulae/skhd
skhd --start-service
brew install koekeishiya/formulae/yabai
yabai --start-service

Then edit your .config/yabai/yabairc:

yabai -m config layout bsp
yabai -m config window_placement second_child
yabai -m config mouse_follows_focus on
yabai -m mouse_drop_action swap

yabai -m config top_padding 6
yabai -m config bottom_padding 6
yabai -m config left_padding 6
yabai -m config right_padding 6
yabai -m config window_gap 6

And your .config/skhd/skhdrc:

# Window Tree Manipulation
shift + alt - r : yabai -m space --rotate 270
shift + alt - y : yabai -m space --mirror y-axis
shift + alt - x : yabai -m space --mirror x-axis

# Window Manipulation
shift + alt - f : yabai -m window --toggle zoom-fullscreen

# Focus Window
alt - h : yabai -m window --focus west
alt - l : yabai -m window --focus east
alt - j : yabai -m window --focus south
alt - k : yabai -m window --focus north

And restart yabai (skhd supports hot reload):

yabai --restart-service

Note that the above yabai config doesn’t require to disable the System Integrity Protection

If you like yabai and skhd, consider supporting koekeishiya who supports both projects.


Me

A creative thinker who is not afraid to challenge the norm. His diverse track record includes failed startups, approved patents and scientific publications in top conferences and journals. On a mission to protect what matters most to you.