Scripting your Mac: Getting started

I’m switching from Spectacle to Mjolnir mostly as an excuse to learn Lua. I’ve noticed that introductory documentation is a little sparing, so I figure I may as well start writing some.

If you’ve never programmed in Lua before, you may want to run through Learn Lua in Y minutes before you begin.

We’re going to work our way through building a subset of common tiling window managers like Spectacle and SizeUp.

First let’s build the traditional “Hello World!”.

We’ll need to install Mjolnir first, so download the latest release, move it into your Applications folder, and fire it up.

This example will need a couple libraries to work, so we’ll need to install the mjolnir.hotkey and mjolnir.alert rocks:

luarocks install mjolnir.hotkey
luarocks install mjolnir.alert

Then in your config (usually ~/.mjolnir/init.lua) file enter:

local hotkey = require "mjolnir.hotkey"
local alert = require "mjolnir.alert"

hotkey.bind({"cmd", "alt", "ctrl"}, "H", function()
  alert.show("Hello World!")
end)

Reload your config and press Cmd+Alt+Ctrl+H. You should see a bubble in the middle of the screen with the text “Hello World!”

Now that we understand the basic parts, we’re ready to move onto basic motion.

12% combined

The USDA standards for processed, packaged “Salisbury steak” require a minimum content of 65% meat, of which up to 25% can be pork, except if defatted beef or pork is used, the limit is 12% combined. No more than 30% may be fat. Meat byproducts are not permitted; however, beef heart meat is allowed. Extender (bread crumbs, flour, oat flakes, etc.) content is limited to 12%, except isolated soy protein at 6.8% is considered equivalent to 12% of the others.

Wikipedia, Salisbury steak.

Page 2 of 10