summaryrefslogtreecommitdiff
path: root/link
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-09-21 18:30:47 +0300
committerIgor Soarez <igor@soarez.org>2026-09-21 18:30:47 +0300
commit94a8f1ff31a804a4dfa46ce287e30bf4691ae637 (patch)
tree44e5e891ac462711326d334bda905f4cd1823fc6 /link
parent7f0049952bba4ef0e22bf25dc85da6cdfe38f104 (diff)
hammerspoon: shared helpers move to dotlib.lua, which local.lua can require
A machine's local.lua is a separate chunk, so init.lua's locals were invisible to it and anything it wanted -- hotkey(), the mod tables, type_text -- had to be copied. They live in dotlib.lua now, linked beside init.lua, and both files reach them the same way: require("dotlib"). init.lua keeps its own vocabulary by aliasing what it uses, so the 500 lines below are untouched. It prepends its own directory to package.path first: Hammerspoon already puts the config directory there (Contents/Resources/ setup.lua), but taking it from this file's path holds however the config was found. A machine that pulls without re-linking has no dotlib.lua beside init.lua, which would lose every hotkey silently -- that case notifies and names the fix. Checked with a stubbed hs: the module's hotkey, focus, execute, type_text and type_current_date all behave, and local-example.lua binds its four keys through it.
Diffstat (limited to 'link')
-rwxr-xr-xlink/hammerspoon.sh3
1 files changed, 3 insertions, 0 deletions
diff --git a/link/hammerspoon.sh b/link/hammerspoon.sh
index 71c9c91..7c3f2a0 100755
--- a/link/hammerspoon.sh
+++ b/link/hammerspoon.sh
@@ -9,6 +9,9 @@ set -euo pipefail
source "$(dirname "$0")/lib.sh" "$@"
link "$config_dir/hammerspoon/init.lua" "$xdg_config_dir/hammerspoon/init.lua"
+# The helpers init.lua and a machine's own local.lua both require. Linked as its
+# own file, not the directory: that directory is where local.lua lives.
+link "$config_dir/hammerspoon/dotlib.lua" "$xdg_config_dir/hammerspoon/dotlib.lua"
if [[ "$(uname)" == "Darwin" ]]
then