Vincent Garrigues     Blog     Talks     Feed

How to set up Mjolnir for window management

After updating my mac to El Capitan, I was about to re-install my habitual window manager (Divvy), but because it’s Sunday, and the grass is always greener elsewhere, I started looking for an alternative.

The usual suspect showed up: Moom. I used it before but as with Divvy, there was something I didn’t quite like with it.

But then I stumbled on a gem: Mjolnir.

Mjolnir is an OS X app that lets you automate common tasks using the language Lua.

So, yeah. Something even less user friendly than a regular window manager, but I haven’t done any Lua yet and I can sync the config across multiple machines: SOLD. To top it off, the logo is awesome.

How to make Mjolnir resize your windows

First, install Mjolnir and enable accessibility:

Enable accessibility in Mjolnir

Let’s install Lua and LuaRocks (The Lua package manager), we’ll use homebrew for this:

$ brew update
$ brew install lua

Then we need to install a few modules:

$ luarocks install mjolnir.hotkey
$ luarocks install mjolnir.application
$ luarocks install mjolnir.bg.grid

You can find the entire list of modules here: http://rocks.moonscript.org/search?q=mjolnir

Now the fun starts, let’s create ~/.mjolnir/init.lua and add a few window resize shortcuts:

While writing the scripts, use the Mjolnir console to reload the file. Just type mjolnir.reload():

Mjolnir console

You can install Mjolnir’s documentation in Dash. Just search for it in the User contributed section.

The above script is very basic and there’s a lot of repetition. Since we’re basically using a grid based layout, there’s already a module for that: mjolnir.bg.grid

The program then becomes simpler and shorter:

Happy scripting!

If you want to learn more, I can recommend this blog post: Using Mjolnir