From 94a8f1ff31a804a4dfa46ce287e30bf4691ae637 Mon Sep 17 00:00:00 2001 From: Igor Soarez Date: Mon, 21 Sep 2026 18:30:47 +0300 Subject: 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. --- link/hammerspoon.sh | 3 +++ 1 file changed, 3 insertions(+) (limited to 'link') 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 -- cgit v1.2.3