From 3848d890979bd5fafae92054f85061edf10edff3 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Fri, 29 May 2026 11:18:15 +0100 Subject: fix(suspend): make zellij inhibit watcher resilient to local-only sessions The previous watcher exited immediately whenever no SSH-spawned zellij was present. That caused a start-rate-limit storm: .path triggers service (zellij dir non-empty) -> watcher exits because no SSH zellij -> service stops -> .path retriggers (zellij dir still non-empty) -> ... 5 starts in 10s, systemd stops the path unit -> no inhibitor ever again, even after you SSH in Restructure so the watcher stays alive for the entire zellij socket directory lifetime and acquires/releases its own systemd-inhibit lock dynamically based on SSH-zellij presence: * Watcher now polls and exits only when the zellij socket dir is empty, matching the .path's trigger condition so it never re-fires while zellij is alive. * systemd-inhibit removed from ExecStart - watcher self-inhibits via a child 'systemd-inhibit ... sleep infinity' it can terminate on demand. * StartLimitIntervalSec=0 on the service as belt-and-braces against any future regression of the cycle. Recovery from the rate-limit hit: systemctl --user reset-failed zellij-inhibit-suspend.service zellij-inhibit-suspend.path systemctl --user daemon-reload systemctl --user restart zellij-inhibit-suspend.path --- dot_config/systemd/user/zellij-inhibit-suspend.service | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (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 index ed15fff..7c73c64 100644 --- a/dot_config/systemd/user/zellij-inhibit-suspend.service +++ b/dot_config/systemd/user/zellij-inhibit-suspend.service @@ -1,19 +1,21 @@ [Unit] -Description=Hold a systemd-inhibit lock while SSH-spawned zellij sessions exist +Description=Stay alive while any zellij session exists; inhibit suspend if SSH-spawned Documentation=man:systemd-inhibit(1) man:zellij(1) # Independent of any graphical session: this is meant to run on # headless SSH-attached hosts too. The watcher itself decides whether # the current zellij activity warrants inhibiting (SSH-spawned only), -# so a local zellij session won't keep the laptop awake. +# and acquires/releases its own systemd-inhibit lock dynamically. It +# stays alive for the whole zellij dir lifetime so the .path unit does +# not retrigger us in a busy loop when only local zellij sessions are +# active. +# Disable systemd's default start-rate limiter: even though the +# refactored watcher should not cycle anymore, a zero rate-limit makes +# this unit resilient if the user kills it manually. +StartLimitIntervalSec=0 [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 +ExecStart=%h/.local/bin/zellij-inhibit-watcher # Don't auto-restart: the .path unit reactivates us on the next session. Restart=no -- cgit v1.3.1