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.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/config/hammerspoon/local-example.lua b/config/hammerspoon/local-example.lua
new file mode 100644
index 0000000..2ddfe15
--- /dev/null
+++ b/config/hammerspoon/local-example.lua
@@ -0,0 +1,29 @@
+-- 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.
+--
+-- 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.
+
+-- 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)
+
+-- 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)
+
+-- Anything else Hammerspoon can do belongs here just as well.
+hs.hotkey.bind({ "ctrl", "alt" }, "m", function()
+ hs.alert.show(hs.host.localizedName())
+end)