From 01df321e907b6c8568bb8622eb44a5c1486a0631 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 29 May 2026 11:18:13 +0100 Subject: feat(suspend): hold inhibit lock while any zellij session exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../systemd/user/zellij-inhibit-suspend.service | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 dot_config/systemd/user/zellij-inhibit-suspend.service (limited to 'dot_config/systemd/user/zellij-inhibit-suspend.service') diff --git a/dot_config/systemd/user/zellij-inhibit-suspend.service b/dot_config/systemd/user/zellij-inhibit-suspend.service new file mode 100644 index 0000000..9e9ab40 --- /dev/null +++ b/dot_config/systemd/user/zellij-inhibit-suspend.service @@ -0,0 +1,19 @@ +[Unit] +Description=Hold a systemd-inhibit lock while zellij sessions exist +Documentation=man:systemd-inhibit(1) man:zellij(1) +# Independent of any graphical session: this is meant to run on +# headless SSH-attached hosts too. + +[Service] +Type=simple +ExecStart=systemd-inhibit \ + --what=sleep:idle:handle-lid-switch \ + --who=zellij \ + --why=Active\x20zellij\x20sessions \ + --mode=block \ + %h/.local/bin/zellij-inhibit-watcher +# Don't auto-restart: the .path unit reactivates us on the next session. +Restart=no + +[Install] +WantedBy=default.target -- cgit v1.3.1