config/hammerspoon/local-example.lua (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
-- Example ~/.config/hammerspoon/local.lua: Hammerspoon for one machine only.
--
-- Not linked and never synced -- write it by hand where it is wanted. Only
-- init.lua is linked into ~/.config/hammerspoon, so a file beside it there is
-- the machine's own and in no repo. init.lua loads it last, inside a pcall: it
-- can override anything set there, and a mistake in it is reported without
-- taking the rest of the config down.
--
-- Reload with ctrl-shift-alt-h, as with any other change.
--
-- The helpers init.lua uses are in dotlib.lua, linked beside it, so this file
-- calls them the same way it does: hotkey(key, mods, fn), the mod tables, and
-- focus/execute/type_text. hs.* is available too, for anything not in there.
local lib = require("dotlib")
local hotkey, mods = lib.hotkey, lib.mods
-- Take a key over. Binding a combination init.lua already bound wins, because
-- hs.hotkey stacks bindings per combination and this one is enabled last.
hotkey('1', mods.ca, lib.focus("Slack"))
-- Type something only this machine knows about.
hotkey('9', mods.csa, lib.type_text('someone@example.com'))
-- Give a key back to the OS or another app: bind it to nothing. A binding from
-- init.lua cannot be deleted from here -- it keeps no reference to the hotkey
-- object -- so shadowing it with a no-op is how it is switched off.
hotkey('0', mods.cag, function() end)
-- Anything else Hammerspoon can do belongs here just as well.
hotkey('m', mods.ca, function()
hs.alert.show(hs.host.localizedName())
end)
|