pub fn install_hooks(exe: &str) -> i32Expand description
Register the hook for the turn boundaries, and for a tool having run.
Through jq, deliberately, and this is the one place a fork is the right
answer rather than a leftover. settings.json is a file the AGENT rewrites
for itself, so anything that mangles it is a config lost, and hand-rolled JSON
editing over somebody’s real configuration is exactly how that happens. jq
gets the merge right, preserves everything it does not touch, and refuses an
unparseable file rather than replacing it.
The command string is what makes the entry idempotent, so it has to be spelled
the same way every time: a config managed from somewhere else (chezmoi) that
spells it differently would otherwise end up with the hook registered twice,
firing twice per event. Which is why a spelling already IN the file wins over
this binary’s own path. current_exe() resolves symlinks, so a file holding
~/.local/bin/taimux hook, written when the launcher was installed there,
would otherwise gain a second entry under the build path the symlink points
at the first time anyone adds an event. Found by adding two.