Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions systemd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Systemd Timer for tmux-resurrect Auto-Save

An alternative to the default `status-right` based auto-save that uses a systemd user timer instead.

## Why?

The default auto-save mechanism uses `#()` command substitution in tmux's `status-right`. This command runs on every status bar refresh for every attached client. With many sessions and clients, this can cause significant CPU overhead.

A systemd timer runs the save script once per interval, regardless of the number of sessions or clients.

## Setup

Copy the unit files to your systemd user directory:

```bash
cp systemd/tmux-resurrect-save.service ~/.config/systemd/user/
cp systemd/tmux-resurrect-save.timer ~/.config/systemd/user/
```

Adjust the path in the service file if your tmux-resurrect is installed somewhere other than `~/.tmux/plugins/tmux-resurrect/`.

Enable and start the timer:

```bash
systemctl --user daemon-reload
systemctl --user enable --now tmux-resurrect-save.timer
```

Then disable the status-right based auto-save in your `tmux.conf`:

```tmux
set -g @continuum-save-interval '0'
```

## Verify

Check the timer status:

```bash
systemctl --user list-timers | grep tmux
```

Manually trigger a save:

```bash
systemctl --user start tmux-resurrect-save.service
```
6 changes: 6 additions & 0 deletions systemd/tmux-resurrect-save.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=Auto-save tmux sessions via tmux-resurrect

[Service]
Type=oneshot
ExecStart=/bin/bash -c 'if tmux info &>/dev/null; then "$HOME/.tmux/plugins/tmux-resurrect/scripts/save.sh" quiet; fi'
9 changes: 9 additions & 0 deletions systemd/tmux-resurrect-save.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Auto-save tmux sessions every 15 minutes

[Timer]
OnBootSec=5min
OnUnitActiveSec=15min

[Install]
WantedBy=timers.target