config/systemd/user/claude-sessions-save.service: source of truth for the shutdown service, version-controlled alongside the scripts it calls. scripts/install-systemd.sh: idempotent install script — copies the service file to ~/.config/systemd/user/, reloads the daemon, and enables + starts the service. Run on any new machine to wire up graceful Claude session shutdown.
19 lines
667 B
Desktop File
19 lines
667 B
Desktop File
[Unit]
|
|
Description=Gracefully exit Claude Code sessions before shutdown
|
|
Documentation=https://github.com/oreillyit/claude-foundations
|
|
# Run before the system begins tearing down the session
|
|
Before=shutdown.target halt.target reboot.target poweroff.target
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
RemainAfterExit=yes
|
|
# ExecStart is a no-op — the service exists purely for its ExecStop
|
|
ExecStart=/bin/true
|
|
# On stop (triggered at shutdown): gracefully exit all Claude tmux sessions
|
|
ExecStop=%h/dev/claude/projects/claude-foundations/scripts/claude-sessions-shutdown
|
|
# Allow up to 120s for Claude sessions to save and exit cleanly
|
|
TimeoutStopSec=120
|
|
|
|
[Install]
|
|
WantedBy=default.target
|