feat(keep-awake): optionally block lid switch suspend while active#2816
Draft
sweenu wants to merge 1 commit into
Draft
feat(keep-awake): optionally block lid switch suspend while active#2816sweenu wants to merge 1 commit into
sweenu wants to merge 1 commit into
Conversation
Keep awake only speaks the Wayland idle-inhibit protocol (plus gating DMS's own IdleMonitors), so on laptops where suspend is triggered by closing the lid - a logind hardware event - it has no effect. Add an idleInhibitLidSwitch setting (default off). While keep awake is active, the DMS daemon now takes a block-mode handle-lid-switch logind inhibitor via the existing D-Bus inhibit helper, released when keep awake ends or the daemon shuts down. logind always honors handle-lid-switch locks regardless of LidSwitchIgnoreInhibited. The inhibitor is scoped to handle-lid-switch only, not sleep, so explicit suspend from the power menu keeps working while keep awake is on. New loginctl.setLidInhibitorEnabled API method (bumps API to v28); the shell syncs it on keep-awake toggle, setting change, and daemon reconnect. Toggle lives in Settings > Power next to lock-before-suspend. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Keep awake only speaks the Wayland idle-inhibit protocol (an
IdleInhibitoron the bar surface) plus gating DMS's ownIdleMonitors. On laptops where suspend is triggered by closing the lid — a logind hardware event (HandleLidSwitch=) — keep awake has no effect: no Wayland idle inhibitor can suppress lid handling, so the machine suspends anyway.Solution
New setting
idleInhibitLidSwitch(default off). While keep awake is active, the DMS daemon takes a block-modehandle-lid-switchlogind inhibitor via the existingm.inhibit()D-Bus helper, and releases it when keep awake ends or the daemon shuts down. logind always honorshandle-lid-switchlocks regardless ofLidSwitchIgnoreInhibited=, so this works without any logind config changes.The inhibitor is deliberately scoped to
handle-lid-switchonly (notsleep): a block-mode sleep inhibitor would also make explicit suspend from the power menu fail while keep awake is on.Note: with the lid action blocked, the internal panel stays on when the lid is closed — logind's suspend was what turned it off. Users who want the panel dark can add a compositor lid-switch bind (e.g. Hyprland
bindl = , switch:on:Lid Switch, exec, hyprctl dispatch dpms off eDP-1); that's compositor territory, so intentionally out of scope here.Changes
core (API v27 → v28):
loginctl.setLidInhibitorEnabledmethod (params:enabled)Manager.SetLidInhibitorEnabled()— idempotent acquire/release under its own mutex, mirroring the sleep inhibitorManager.Close()quickshell:
idleInhibitLidSwitchinSettingsSpec.js+SettingsData.qml(default off)SessionService.syncLidInhibitor()— sends the daemon request, gated onloginctlAvailable+ API ≥ 28; synced on keep-awake enable/disable, setting change, and daemon reconnect (re-establishes the inhibitor ifdmsrestarts while keep awake is on)settings_search_index.jsonTesting
go build ./...,go vet,gofmtclean; fullloginctltest suite passes incl. 4 new tests; all pre-commit hooks passHandleLidSwitch=suspend-then-hibernate) running this branch:systemd-inhibit --listshowsDankMaterialShell … handle-lid-switch … Keep awake … blocksleep/delaylock remains); re-enable re-acquires it🤖 Generated with Claude Code