Skip to content

Run the watcher as a launch agent

freehand watch notices new notebook pages, new marks and new commits in your repos, and acts on them. Run in a terminal, it stops when you close it. As a launch agent, macOS runs one check a minute in the background and starts it again when you log in.

  • A working watch config. freehand init writes one. Check yours with freehand watch --status, which shows what it watches and what it has handled so far. The keys are in the watch config reference.
  • A Mac. --install is for macOS. On Linux, run freehand watch --once from cron.
Terminal window
freehand watch --install

This writes ~/Library/LaunchAgents/dev.freehand.watch.plist and loads it. The agent runs the same command with --once every minute, and logs to ~/.freehand/watch.log.

launchd starts programs with a bare PATH, which would miss uv, claude and anything else your then: command runs. So the agent keeps the PATH you installed it from. If you install a tool later, run freehand watch --install again.

Terminal window
freehand watch --status # what it watches, and what it has handled
tail -f ~/.freehand/watch.log

Edit ~/.freehand/config.yml. The agent reads it on every check, so there’s nothing to reload. To change where the config is, or to use folders and a command instead of a config, install again with the new arguments: freehand watch <folder>... --run "<command>" --install.

Terminal window
freehand watch --uninstall
  • It polls. Sync apps lose file events, especially while a laptop sleeps, and listing a few folders costs nothing.
  • It waits for quiet. Nothing is read until the folder has gone quiet for quiet_minutes (3 by default), so a sync that’s still uploading isn’t read half done.
  • It never acts twice. The state file, ~/.freehand/watch.json, records what it has handled.
  • A failed command is tried again. If your then: command exits with anything but 0, the same changes are tried again after five minutes, and the reason is in the log.
  • It hands off to the script. Give your config alive: freehand/inbox and, while the watcher runs, the freehand script leaves reading new pages to your computer. Once the laptop sleeps or shuts for ten minutes, the script takes over again.
  • It stops cleanly. Ctrl-C or SIGTERM stops a running watcher, even in the middle of a check. It ends the command, removes its scratch folder of drawn pages, and saves no state, so the same changes are handled next time. It exits 130 after Ctrl-C and 143 after SIGTERM.