summaryrefslogtreecommitdiff
path: root/config/hammerspoon/local-example.lua
diff options
context:
space:
mode:
Diffstat (limited to 'config/hammerspoon/local-example.lua')
-rw-r--r--config/hammerspoon/local-example.lua19
1 files changed, 11 insertions, 8 deletions
diff --git a/config/hammerspoon/local-example.lua b/config/hammerspoon/local-example.lua
index 2ddfe15..cf2963d 100644
--- a/config/hammerspoon/local-example.lua
+++ b/config/hammerspoon/local-example.lua
@@ -8,22 +8,25 @@
--
-- Reload with ctrl-shift-alt-h, as with any other change.
--
--- Note what is NOT available here: init.lua's `hotkey()` helper and its mod
--- tables (cs, ca, csa, cag, hyp) are locals of that file, and this is a
--- separate chunk. Call hs.hotkey.bind directly and write the modifiers out.
+-- 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.
-hs.hotkey.bind({ "ctrl", "alt" }, "1", function()
- hs.application.launchOrFocus("Slack")
-end)
+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.
-hs.hotkey.bind({ "ctrl", "alt", "cmd" }, "0", function() end)
+hotkey('0', mods.cag, function() end)
-- Anything else Hammerspoon can do belongs here just as well.
-hs.hotkey.bind({ "ctrl", "alt" }, "m", function()
+hotkey('m', mods.ca, function()
hs.alert.show(hs.host.localizedName())
end)