Skip to content

Debounce lid-close suspend so a quick reopen does not sleep in the dark - #12210

Open
ijt wants to merge 2 commits into
omacom:quattrofrom
ijt:fix/lid-close-suspend-race
Open

ijt wants to merge 2 commits into
omacom:quattrofrom
ijt:fix/lid-close-suspend-race

Conversation

@ijt

@ijt ijt commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #12193

Why

logind's default HandleLidSwitch=suspend and Hyprland's lid bind both fire on the same close. A 2-second close/open then commits to S3 with the lid already open. user.slice is frozen, so Hyprland never sees switch:off and the panel stays at the lid-closed backlight. On this machine that looked like a hang and needed a power-button hold.

What

  • Packaged logind drop-in: HandleLidSwitch=ignore (and ExternalPower). Docked stays ignore.
  • omarchy-system-lid-close still locks immediately, then starts omarchy-system-lid-suspend.
  • That helper waits 3s (override OMARCHY_LID_SUSPEND_DELAY), then systemctl suspend only if the lid is still shut, there is no external monitor, and suspend is not toggled off.
  • Lid open (omarchy-system-lid-open) cancels the pending job, runs omarchy-system-wake, and forces DPMS on. omarchy-brightness-display on can no-op when dpmsStatus is already true after S3 with backlight saved at 0.
  • systemd-sleep post hook wakes the session 1s after thaw, because the compositor missed the lid event while frozen.
  • Migration reloads logind once the drop-in is on disk.

Not in this PR

The 20s delay used locally on a MacBookPro14,2. That number is because Alpine Ridge S3 resume is ~7s on that hardware (see the sibling Alpine Ridge PR). The portable debounce is 3s.

Test plan

  • Undocked: close lid 2s, open. Session locks, does not suspend, panel comes back.
  • Undocked: close lid, leave closed. Suspends after ~3s.
  • Docked: lid close stays awake on the external display.
  • omarchy toggle suspend off: lid close locks, does not suspend.
  • ./test/cli and the lid-* / monitor-recovery shell tests.

Proven on Omarchy 4.0.2-1, MacBookPro14,2, kernel 7.1.9-arch1-2.

logind and Hyprland both acted on the same lid event, so a 2s close/open
committed to S3 with the lid already open. user.slice is frozen then, so
the compositor never turns the panel back on.
Those Alpine Ridge machines take about 7s to resume, so a 3s debounce
still drops a glance-close into that wait. Default stays 3s; T1 MacBook
Pros use 20s. /etc/omarchy/lid-suspend-delay overrides both.
@ijt

ijt commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: T1 MacBook Pros (MacBookPro13,x / 14,x) now wait 20s before S3 instead of 3s. Those Alpine Ridge machines take ~7s to resume, so a short close still felt like a hang.

Everyone else stays at 3s. Any machine can set /etc/omarchy/lid-suspend-delay (one number, seconds).

@jandrusk

Copy link
Copy Markdown

Thanks for the debounce design — agreeing Omarchy should own lid suspend if we want cancel-on-reopen.

Blocked on merge right now:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lid close starts suspend immediately; a quick reopen leaves a dark screen

3 participants