Hammerspoon
Overview
Hammerspoon* is an automation tool for MacOS. It is basically a wrapper around MacOS API's, that now can be scripted using Lua.
Hammerspoon can interact with windows, applications, mouse pointers, filesystem objects, audio devices, batteries, screens, low-level keyboard/mouse events, clipboards, location services, wifi, and more.
This application is a fork of Mjolnir, which is based on Hydra. Both Mjolnir and Hydra are not being developed anymore. This is also the origin of the name Hammerspoon. fork and/or spoon* and Mjolnir, which is the Thor's hammer.
Pre-made plugins are called Spoons and a list of them can be found here.
Examples
Simple Hello World alert:
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function()
hs.alert.show("Hello World")
end)
Send a Hello World notification:
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "W", function()
hs.notify.new({title="Hammerspoon", informativeText="Hello World"}):send()
end)
Using a spoon:
hs.loadSpoon("AClock")
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "C", function()
spoon.AClock:toggleShow()
end)
Configuration reloading:
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function()
hs.reload()
hs.alert.show("Config reloaded!")
end)
Bypass paste blocking:
hs.hotkey.bind({"cmd", "alt"}, "V", function() hs.eventtap.keyStrokes(hs.pasteboard.getContents()) end)