summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/hammerspoon/local-example.lua29
1 files changed, 21 insertions, 8 deletions
diff --git a/config/hammerspoon/local-example.lua b/config/hammerspoon/local-example.lua
index cf2963d..967c14e 100644
--- a/config/hammerspoon/local-example.lua
+++ b/config/hammerspoon/local-example.lua
@@ -8,25 +8,38 @@
--
-- 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.
+-- The helpers are in dotlib.lua, linked beside init.lua. This header is the
+-- same one init.lua has, names included, so a binding can be moved between the
+-- two files unchanged -- which is how a machine takes something out of the
+-- shared config, or the shared config adopts something that started here.
+-- Anything not in the module is still reachable as hs.*.
local lib = require("dotlib")
-local hotkey, mods = lib.hotkey, lib.mods
+
+local focus = lib.focus
+local execute = lib.execute
+local hotkey = lib.hotkey
+local type_text = lib.type_text
+local type_current_date = lib.type_current_date
+local type_random_ids = lib.type_random_ids
+local cs, ca, csa = lib.mods.cs, lib.mods.ca, lib.mods.csa
+local cag, hyp, spc = lib.mods.cag, lib.mods.hyp, lib.mods.spc
-- 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"))
+hotkey('1', ca, focus("Slack"))
-- Type something only this machine knows about.
-hotkey('9', mods.csa, lib.type_text('someone@example.com'))
+hotkey('9', csa, 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)
+hotkey('0', cag, function() end)
+
+-- spc is a key, not a modifier set: it goes in the first argument.
+hotkey(spc, cs, execute('open -a Finder'))
-- Anything else Hammerspoon can do belongs here just as well.
-hotkey('m', mods.ca, function()
+hotkey('m', hyp, function()
hs.alert.show(hs.host.localizedName())
end)