[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) <noreply@anthropic.com>
This commit is contained in:
5
Makefile
5
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) && \
|
||||
|
||||
35
launchd/Library/LaunchAgents/com.powellc.claude-save.plist
Normal file
35
launchd/Library/LaunchAgents/com.powellc.claude-save.plist
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
|
||||
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.powellc.claude-save</string>
|
||||
|
||||
<!-- sh expands $HOME; launchd does not expand ~ in ProgramArguments -->
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/bin/sh</string>
|
||||
<string>-c</string>
|
||||
<string>make -C "$HOME/.dotfiles" claude-save</string>
|
||||
</array>
|
||||
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
||||
</dict>
|
||||
|
||||
<key>StartInterval</key>
|
||||
<integer>1800</integer>
|
||||
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
|
||||
<key>StandardOutPath</key>
|
||||
<string>/tmp/claude-save.out</string>
|
||||
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/tmp/claude-save.err</string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user