diff options
Diffstat (limited to 'dot_local/bin/executable_zellij-inhibit-watcher')
| -rwxr-xr-x | dot_local/bin/executable_zellij-inhibit-watcher | 20 |
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 |
