Hammerspoon Lua scripting for system-level macOS automation

Hammerspoon is the programmable layer โ€” anything that requires Lua logic, low-level window manipulation, or system events that BTT and KM can’t reach.

Config: ~/.hammerspoon/init.lua โ€” the main entry point. Modular configs split into separate files and required from init.lua.

HammerFlow

HammerFlow manages Hammerspoon hotkey bindings in TOML configuration files, making them readable and maintainable without editing raw Lua.

Config location: ~/.hammerspoon/hammerflow.toml (or similar โ€” check init.lua for exact path)

Format:

[[bindings]]
key = "h"
mods = ["ctrl", "alt"]
action = "some_action"
description = "Do something"
Installed Spoons

Spoons are Hammerspoon plugins stored in ~/.hammerspoon/Spoons/. List installed:

ls ~/.hammerspoon/Spoons/

Common useful Spoons: MiroWindowsManager (window grid), ReloadConfiguration (auto-reload on save), SpoonInstall (install other Spoons).

BTT Integration

Hammerspoon can call BTT named triggers and vice versa:

Hammerspoon โ†’ BTT:

hs.urlevent.openURL("btt://trigger_named/?trigger_name=TRIGGER_NAME")

Reload config:

hs.reload()

Or use the menu bar Hammerspoon icon โ†’ Reload Config.

Debugging

Open the Hammerspoon console from the menu bar icon to see print output and errors. Add print("debug message") anywhere in Lua for tracing.

Watch the console when reloading config โ€” syntax errors appear immediately.