aboutsummaryrefslogtreecommitdiff
path: root/etc/tmux/continuum-throttle.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2026-06-11 06:27:42 -0300
committerEuAndreh <eu@euandre.org>2026-06-11 06:27:42 -0300
commit7ee18d818a13d93ff9711e1d9ea554f572fa1eb1 (patch)
tree9e469f322ef6c3a3499c4067385a492dbc056be4 /etc/tmux/continuum-throttle.sh
parentetc/sh/rc: Remove commented POSIXLY_CORRECT (diff)
downloaddotfiles-7ee18d818a13d93ff9711e1d9ea554f572fa1eb1.tar.gz
dotfiles-7ee18d818a13d93ff9711e1d9ea554f572fa1eb1.tar.xz
etc/tmux/: Try to make the background save less wasteful
Diffstat (limited to 'etc/tmux/continuum-throttle.sh')
-rwxr-xr-xetc/tmux/continuum-throttle.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/etc/tmux/continuum-throttle.sh b/etc/tmux/continuum-throttle.sh
new file mode 100755
index 00000000..e0e3dabb
--- /dev/null
+++ b/etc/tmux/continuum-throttle.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# Throttle wrapper around tmux-continuum's save script.
+#
+# tmux re-renders status-right per client per status-interval, so the
+# upstream save script is invoked far more often than it can possibly do
+# useful work. This wrapper short-circuits the common case using only
+# bash builtins (no fork, no subprocess) and only execs the real script
+# when the throttle window has elapsed.
+
+throttle=60
+stamp="${XDG_RUNTIME_DIR:-/tmp}/tmux-continuum-throttle.stamp"
+real=~/.guix-home/profile/share/tmux-plugins/continuum/scripts/continuum_save.sh
+
+last=0
+[[ -r $stamp ]] && read -r last < "$stamp"
+(( EPOCHSECONDS - last < throttle )) && exit 0
+
+printf '%s\n' "$EPOCHSECONDS" > "$stamp"
+exec "$real"