aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/dot_config
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config')
-rw-r--r--dot_config/systemd/user/zellij-inhibit-suspend.path12
-rw-r--r--dot_config/systemd/user/zellij-inhibit-suspend.service19
-rw-r--r--dot_config/zsh/dot_zprofile13
3 files changed, 39 insertions, 5 deletions
diff --git a/dot_config/systemd/user/zellij-inhibit-suspend.path b/dot_config/systemd/user/zellij-inhibit-suspend.path
new file mode 100644
index 0000000..72c509c
--- /dev/null
+++ b/dot_config/systemd/user/zellij-inhibit-suspend.path
@@ -0,0 +1,12 @@
+[Unit]
+Description=Activate suspend inhibitor whenever zellij has a live session
+
+[Path]
+# %t expands to $XDG_RUNTIME_DIR (typically /run/user/$UID); zellij keeps
+# its per-version session sockets under this directory. Whenever the dir
+# transitions from empty to non-empty, the service is (re)activated.
+DirectoryNotEmpty=%t/zellij
+Unit=zellij-inhibit-suspend.service
+
+[Install]
+WantedBy=default.target
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
diff --git a/dot_config/zsh/dot_zprofile b/dot_config/zsh/dot_zprofile
index 02991cb..a26209b 100644
--- a/dot_config/zsh/dot_zprofile
+++ b/dot_config/zsh/dot_zprofile
@@ -151,11 +151,14 @@ case $(uname -n) in
esac
# ── SSH: inhibit suspend/idle while connected ────────────────────────────────
-# A remote session is useless if the laptop suspends mid-command. Wrap the
-# login shell in `systemd-inhibit` so a lock is held for the entire SSH
-# session lifetime (lid close, idle timeout, swayidle, lid-switch handlers
-# all honour it). The lock is released the instant the shell exits, so a
-# clean disconnect restores normal power behaviour.
+# Backstop for SSH sessions that don't use zellij. (The dedicated
+# zellij-inhibit-suspend.path user unit already covers any host that has
+# at least one live zellij session — that one survives detach/disconnect,
+# which this in-shell inhibitor does not.)
+#
+# Wrap the login shell in `systemd-inhibit` so a lock is held for the
+# entire SSH session lifetime; the lock is released the instant the
+# shell exits.
if [[ -n $SSH_CONNECTION && -z $__SSH_SUSPEND_INHIBITED ]] \
&& command -v systemd-inhibit >/dev/null 2>&1; then
export __SSH_SUSPEND_INHIBITED=1