From 35466f0141174cd2f46b770e25fa955947713f1f Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Sun, 28 Jun 2026 21:16:59 -0400 Subject: [PATCH] power: keep wayback awake lid-closed (never-sleep) wayback runs as an always-on router living lid-closed in the van, but stock logind HandleLidSwitch=suspend would sleep it on lid close (even on AC). Add a logind drop-in that ignores the lid in all states and mask every sleep target so idle/GUI/stray `systemctl suspend` can't suspend it either. - power/10-vanlink-nolid.conf -> /etc/systemd/logind.conf.d/ - deploy.sh: install drop-in, mask sleep/suspend/hibernate/hybrid-sleep, restart systemd-logind - README: power/ layout row, never-sleep operation notes + reversal recipe Co-Authored-By: Claude Opus 4.8 --- README.md | 19 +++++++++++++++++++ deploy.sh | 7 +++++++ power/10-vanlink-nolid.conf | 6 ++++++ 3 files changed, 32 insertions(+) create mode 100644 power/10-vanlink-nolid.conf diff --git a/README.md b/README.md index 9c7e41a..87b95ef 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,14 @@ This directory is the source of truth. The live system files live under `/etc`, ### `cockpit/vanrouter/` — web UI `manifest.json`, `index.html`, `vanrouter.css`, `vanrouter.js` → `/usr/share/cockpit/vanrouter/`. +### `power/` — never sleep +| file | → installs to | purpose | +|---|---|---| +| `10-vanlink-nolid.conf` | `/etc/systemd/logind.conf.d/10-vanlink-nolid.conf` | logind ignores the lid in all states (closed / on AC / docked) | + +`deploy.sh` additionally **masks** `sleep.target suspend.target hibernate.target hybrid-sleep.target` +(no repo file — symlinks to `/dev/null` under `/etc/systemd/system/`) so nothing else can suspend either. + --- ## 3. Components & how to operate @@ -131,6 +139,17 @@ This directory is the source of truth. The live system files live under `/etc`, - Read-only status works as any user; Prefer/Up/Down/Restart need *Administrative access* (polkit). - **Prefer** sets the manual WAN preference (see *Manual preference* above); **Up/Down** connect/disconnect the NM device; **Restart** restarts hostapd. +### Never sleep (lid-closed operation) +- wayback lives lid-closed in the van and must stay up. Stock logind `HandleLidSwitch=suspend` would sleep it on lid close (even on AC). The `power/10-vanlink-nolid.conf` drop-in sets all three lid actions to `ignore`; `deploy.sh` also masks every sleep target so idle / GUI / a stray `systemctl suspend` can't suspend it. +- Verify: `busctl get-property org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager HandleLidSwitch` → `"ignore"`, and `systemctl is-enabled suspend.target` → `masked`. `busctl call ... CanSuspend` should return `"no"`. +- **To re-enable sleep** (e.g. if wayback is ever a laptop again): + ```bash + sudo rm /etc/systemd/logind.conf.d/10-vanlink-nolid.conf + sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target + sudo systemctl restart systemd-logind + ``` + (then remove the `power/` block from `deploy.sh`, or the next deploy re-applies it). + --- ## 4. Deploy / rebuild diff --git a/deploy.sh b/deploy.sh index 969c1c5..7300a71 100755 --- a/deploy.sh +++ b/deploy.sh @@ -33,6 +33,11 @@ echo "== cockpit plugin ==" install -d /usr/share/cockpit/vanrouter install -m0644 cockpit/vanrouter/* /usr/share/cockpit/vanrouter/ +echo "== power / never-sleep ==" +install -D -m0644 power/10-vanlink-nolid.conf /etc/systemd/logind.conf.d/10-vanlink-nolid.conf +# Belt-and-suspenders: a router must never suspend from idle, GUI, or a stray `systemctl suspend`. +systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target >/dev/null 2>&1 || true + echo "== apply ==" sysctl --system >/dev/null systemctl daemon-reload @@ -40,6 +45,8 @@ systemctl daemon-reload # can never satisfy "online" and just burns its 120s timeout, stalling network-online.target # and ZeroTier by ~2min every boot. Real uplink readiness is covered by NetworkManager-wait-online. systemctl mask systemd-networkd-wait-online.service >/dev/null 2>&1 || true +# pick up the lid drop-in (re-execs logind; does NOT drop the network) +systemctl restart systemd-logind >/dev/null 2>&1 || true systemctl unmask hostapd >/dev/null 2>&1 || true systemctl enable regdomain.service hostapd van-ap-dnsmasq nftables systemd-networkd van-failover >/dev/null 2>&1 || true # restart in dependency order; AP iface IP first, then hostapd/dnsmasq, then NAT/failover diff --git a/power/10-vanlink-nolid.conf b/power/10-vanlink-nolid.conf new file mode 100644 index 0000000..d23c996 --- /dev/null +++ b/power/10-vanlink-nolid.conf @@ -0,0 +1,6 @@ +[Login] +# wayback is an always-on router living lid-closed in the van. +# Default logind suspends on lid close (incl. on AC); ignore the lid in every state. +HandleLidSwitch=ignore +HandleLidSwitchExternalPower=ignore +HandleLidSwitchDocked=ignore