aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_local/bin/executable_zellij-inhibit-watcher
diff options
context:
space:
mode:
authorLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-29 11:18:13 +0100
committerLibravatar sommerfeld <sommerfeld@sommerfeld.dev>2026-05-29 11:18:13 +0100
commit01df321e907b6c8568bb8622eb44a5c1486a0631 (patch)
treebb9d76bf9bddd982fc079e045414e138154fa0ef /dot_local/bin/executable_zellij-inhibit-watcher
parent263f39704ae5e8f44a79d64dce2be048009b4df6 (diff)
downloaddotfiles-01df321e907b6c8568bb8622eb44a5c1486a0631.tar.gz
dotfiles-01df321e907b6c8568bb8622eb44a5c1486a0631.tar.bz2
dotfiles-01df321e907b6c8568bb8622eb44a5c1486a0631.zip
feat(suspend): hold inhibit lock while any zellij session exists
The SSH-shell inhibitor in dot_zprofile is bound to the lifetime of the login shell, so it disappears the moment the user detaches a zellij session and disconnects — defeating the whole point of using zellij for persistent remote work. Add a user-scope path+service+watcher trio that ties the inhibit lock to the existence of zellij sessions instead: - dot_local/bin/executable_zellij-inhibit-watcher Polls `zellij list-sessions --short` every 15s, exits when none remain. Override poll interval via $ZELLIJ_INHIBIT_POLL. - dot_config/systemd/user/zellij-inhibit-suspend.service Wraps the watcher in `systemd-inhibit --what=sleep:idle:handle-lid-switch --mode=block`. When the watcher exits, the service stops and the lock is released. - dot_config/systemd/user/zellij-inhibit-suspend.path Activates the service whenever $XDG_RUNTIME_DIR/zellij becomes non-empty (i.e. zellij creates its first session socket). Re-fires on every empty→non-empty transition. Enable via systemd-units/user.txt (the .path unit; the service is on-demand). The existing SSH-shell inhibitor is kept as a backstop for non-zellij remote sessions and is now documented as such. VM (nix/vm.nix) deliberately not updated: the Ubuntu remote-dev VM never suspends, so the inhibit machinery would be inert there.
Diffstat (limited to 'dot_local/bin/executable_zellij-inhibit-watcher')
-rwxr-xr-xdot_local/bin/executable_zellij-inhibit-watcher20
1 files changed, 20 insertions, 0 deletions
diff --git a/dot_local/bin/executable_zellij-inhibit-watcher b/dot_local/bin/executable_zellij-inhibit-watcher
new file mode 100755
index 0000000..0af20dd
--- /dev/null
+++ b/dot_local/bin/executable_zellij-inhibit-watcher
@@ -0,0 +1,20 @@
+#!/bin/sh
+# Block until no zellij sessions remain.
+#
+# Used as the ExecStart payload of zellij-inhibit-suspend.service: the
+# service wraps this script with `systemd-inhibit`, so the inhibit lock
+# is held for exactly the lifetime of this process. When the last zellij
+# session ends, this script exits 0, the service stops, and the lock is
+# released.
+#
+# A user-level `.path` unit re-activates the service whenever the zellij
+# socket directory becomes non-empty again, so the lock is automatically
+# reacquired on the next `zellij` invocation.
+set -eu
+
+poll=${ZELLIJ_INHIBIT_POLL:-15}
+
+while sessions=$(zellij list-sessions --short 2>/dev/null) &&
+ [ -n "$sessions" ]; do
+ sleep "$poll"
+done