From 8a851413af2a6a5e89cbd07b74db9ae85c8247d7 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Thu, 17 Sep 2026 11:37:30 -0400 Subject: [PATCH] [launchd] Sync Claude session state on macOS Adds a launchd agent that runs the existing claude-save make target every 30 minutes and at login, so macOS machines commit and push session state the way the systemd timer does on Linux. The agent runs through /bin/sh because launchd expands neither ~ nor $HOME in ProgramArguments, and sets PATH explicitly because agents inherit no shell environment. The claude target loads it via launchctl bootstrap on darwin. Co-Authored-By: Claude Opus 5 (1M context) --- Makefile | 5 +++ .../com.powellc.claude-save.plist | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 launchd/Library/LaunchAgents/com.powellc.claude-save.plist diff --git a/Makefile b/Makefile index 45a3c98..4164c00 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,11 @@ claude: systemctl --user daemon-reload && \ systemctl --user enable --now claude-save.timer; \ fi + @if [ $(OS_NAME) = "darwin" ]; then \ + launchctl bootout gui/$$(id -u)/com.powellc.claude-save 2>/dev/null; \ + launchctl bootstrap gui/$$(id -u) ~/Library/LaunchAgents/com.powellc.claude-save.plist && \ + echo "claude: loaded com.powellc.claude-save"; \ + fi claude-save: @cd $(CLAUDE_HISTORY_DIR) && \ diff --git a/launchd/Library/LaunchAgents/com.powellc.claude-save.plist b/launchd/Library/LaunchAgents/com.powellc.claude-save.plist new file mode 100644 index 0000000..498b6a2 --- /dev/null +++ b/launchd/Library/LaunchAgents/com.powellc.claude-save.plist @@ -0,0 +1,35 @@ + + + + + Label + com.powellc.claude-save + + + ProgramArguments + + /bin/sh + -c + make -C "$HOME/.dotfiles" claude-save + + + EnvironmentVariables + + PATH + /opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin + + + StartInterval + 1800 + + RunAtLoad + + + StandardOutPath + /tmp/claude-save.out + + StandardErrorPath + /tmp/claude-save.err + +