Tiling your windows on OSX

Doug Hooker
5 min readMar 22, 2019

--

Making the best of OSX with chunkwm

It’s not easy being a Linux developer in an OSX shop, and it’s even harder to be a productive Linux developer when your workplace’s ecosystem runs on Apple’s locked down “magic” hardware, complete with its proprietary system settings that not even the strongest Unix wizard's sudo can touch.

But I’m here to tell you about my experiences with a pseudo window manager called chunkwm and how it made this penguin lover much happier with the MacBook I was given at work.

A classic tiling wm screenshot using chunkwm

What is ‘chunkwm’ and why should I use it?

Chunkwm is an open-source solution to bring us the tiling window managers which are very popular within the Linux/open source community for their insane amount of customization options and inherent nature of being very friendly to keyboard-only workflows. When used properly, these keyboard-only workflows can dramatically increase your productivity and speed (especially as a developer), and tiling window managers can push that productivity even further.

OSX is not known for being friendly to power user customization like most Linux distributions. Hell even Windows feels more customizable in some cases, especially with the new Linux subsystem feature. But people smarter than me are giving it their best shot to override Apple’s design driven mess and make the best of the Unix power underneath the OS’s shiny shell.

That’s where chunkwm comes in.

It’s not exactly the same as running a native tiling window manager in a Linux environment, as it doesn’t completely replace Apple’s proprietary nature and difficulty to customize, but it replicates the intended tiling effect very well using primarily C++ to interface with the windows displayed on your screen to give a similar flow.

NOTE: while chunkwm still hasn’t gotten to a v1.0, it’s well on its way and has only given me some minor annoyances and issues in the couple weeks I’ve been using it full time.

All the movement here was done using my keyboard thanks to chunkwm and skhd

Installation

If you’re not using Homebrew or MacPorts already, you’ll need one of those to get started. I’d recommend Homebrew as that’s what I use and will be the focus of this tutorial.

First you’re going to want to install chunkwm:

# Tap the repo, making chunkwm available
$ brew tap koekeishiya/formulae
# Install chunkwm
$ brew install chunkwm
# You will likely have to copy the example config to your home directory, unless you already have a chunkwmrc stored there :)
$ cp /usr/local/opt/chunkwm/share/chunkwm/examples/chunkwmrc ~/.chunkwmrc
# Chunkwmrc needs to be executable
$ chmod +x ~/.chunkwmrc

And that’s that! At least for installing the main program…

To check that chunkwm successfully installed, run chunkwm -v and you should get a response something like chunkwm 0.4.8 ().

If you get a “command not found” error or something else is wrong, make sure your Homebrew programs are loaded into your $PATH. For most Bash compatible shells that’s done by adding export PATH="/usr/local/bin:$PATH" to your shell configuration file (i.e. .bash_profile or .zshrc).

At this point if you run brew services start chunkwm (or chunkwm if you don’t want to run it as a service) in your shell, you should see some output in your terminal, likely with a complaint about enabling accessibility control. If you get an error relating to ‘Plugins not being found’, you may not have the program correctly and should reinstall to try again (I had to do this, but everything worked the second time).

Once you’ve got the complaint about adding accessibility access, go ahead and give it permission by going to System Preferences -> Security & Privacy -> Accessibility and checking chunkwm item on the app list.

Once you’ve given chunkwm the permissions it needs, you may have to restart your terminal/process. After that’s done, try running chunkwm in your terminal again. If your windows move around and you get some output in your terminal, chunkwm is good to go!

Adding Keyboard controls

You’re probably asking yourself right about now, “But where are the keyboard controls?”, and you’re totally right, they are missing! Chunkwm itself only handles the window management side of things.

To add on keyboard controls, we need a service called SKHD. It’s made by the creator of chunkwm, so we’re guaranteed some nice interoperability.

To install skhd, run the following command:

# Installs SKHD from the repo
$ brew install koekeishiya/formulae/skhd

Afterwards you’ll want to grab the sample config file and stick it at $HOME/.skhdrc. Once you’ve done this, you can run brew services start skhd (or skhd if you don’t want to jump straight to the service) and it will read your config file at $HOME/.skhdrc! You’ll have to accessibility access to skhd, so please repeat the steps above and go to System Preferences -> Security & Privacy -> Accessibility and give skhd the permissions it needs.

Once you’ve done this, you may need another program/terminal restart, so once you’ve done that, go ahead and run either brew services start skhd or skhd — whichever you did before — and it should be up and running!

NOTE: If you chose not to run chunkwm as a service the first time, you will have to re-run it or give it accessibility permissions should you choose to run it as a service

Once both of them are up and running, try hitting Alt/Opt + ton your terminal window to trigger a floating window.

If it works, then congratulations! You’re running a “tiling window manager” on OSX! That’s no small feat.

If you ran into any errors or your key combinations don’t work, please make sure your ~/.skhdrc file exists and that your ~/.chunkwmrc file exists and is executable!

Some examples of movement, rotation, and floating windows

Next Steps

Now that you’re up and running, I’d recommend getting familiar with all of the different key bindings in your ~/.skhdrc. Feel free to customize and play around with them as you’d like.

Do note that if you want to use some of the options such as “fast switch to desktop” (like $mod + 1–9 desktop switching on i3), you’ll have to enable the scripting addition because of some of the code injections that have to take place. This seems to be unavoidable for now because of the way Apple implements desktop switching, but works pretty well once you’ve enabled the scripting.

Take a look at the docs and you’ll find a lot more than I talked about here! Just about everything you need is there, and anything you can’t find is just a google away.

Here’s to your new WM and newfound productivity!

--

--