Skip to content

Restore brightness when the laptop lid opens - #9637

Closed
crwirth wants to merge 3 commits into
omacom:quattrofrom
crwirth:fix/9628-lid-open-restore-brightness
Closed

crwirth wants to merge 3 commits into
omacom:quattrofrom
crwirth:fix/9628-lid-open-restore-brightness

Conversation

@crwirth

@crwirth crwirth commented Sep 1, 2026

Copy link
Copy Markdown

Summary

After suspend, opening the laptop lid only ran omarchy-hyprland-monitor-clamshell. That reconciles internal/external monitor state but does not turn the panel backlight back on or restore the keyboard backlight.

The idle wake path already does the full restore via omarchy-system-wake:

omarchy-brightness-display on
omarchy-brightness-keyboard restore
omarchy-hyprland-monitor-clamshell >/dev/null 2>&1 || true

On hardware where ACPI backlight restore is slow or incomplete (reported on MacBook10,1 in #9628), lid open left a black internal panel until a power-button press, while idle wake recovered cleanly.

Fix

Point switch:off:Lid Switch at omarchy-system-wake so lid open gets the same restore sequence, then the same clamshell reconciliation wake already performs. Close path is unchanged (omarchy-system-lid-close).

Tests

  • test/shell.d/monitor-recovery-test.sh — binding now expects omarchy-system-wake; asserts wake restores display + keyboard brightness before clamshell
  • test/shell.d/lid-close-test.sh — still passes (close path untouched)
  • test/shell.d/monitor-clamshell-scale-test.sh — still passes

Fixes #9628

The lid-open binding only ran omarchy-hyprland-monitor-clamshell. After a
longer suspend that left the internal panel black on hardware where ACPI
backlight restore is slow or incomplete, while the idle wake path already
turned the display back on and restored the keyboard backlight via
omarchy-system-wake.

Point switch:off:Lid Switch at omarchy-system-wake so lid open gets the
same restore sequence, then the same clamshell reconciliation wake already
performs.

Update monitor-recovery-test to assert the binding and the wake steps.

Fixes #9628

Signed-off-by: fresh3nough <anonwurcod@proton.me>
The comment blamed slow ACPI backlight restore, but omarchy-system-wake restores no backlight level: it enables DPMS. Played on a worker, the panel stays off after a lid open because the lock screen turned DPMS off five seconds after locking and the old binding never turned it back on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and run on an Omarchy worker VM, with a second opinion from Codex Medium.

The fix works. I reproduced #9628 on a worker by locking the session, letting the lock screen blank the panel, then sending a lid close and open through a uinput Lid Switch. On quattro (f45461a), and on this branch with the fix reverted, the panel stays off after the lid opens. At this branch's head it comes back on. The black panel comes from the lock screen turning DPMS off five seconds after it locks. The old binding never turned DPMS back on, and omarchy-system-wake does. ./test/cli passes, and so do monitor-recovery, lid-close and monitor-clamshell-scale, both on this head and merged into current quattro. The full shell suite fails the same 45 tests here as on its merge base: 43 because node is missing on the worker, and two logo tests. None of them come from this change.

Pushed: 2e1673f rewrites the comment above the binding. The old comment blamed slow ACPI backlight restore, but omarchy-system-wake restores no backlight level. It enables DPMS, and that is what fixes the bug.

Two side effects, both found by Codex Medium and checked against the code. Neither is a quick fix, because each changes what lid open is meant to do:

  • After a lid open, the lock screen stays lit until someone touches the keyboard or mouse. The binding turns the panel on without going through the lock screen's runWake(), so idleBlankTimer is never re-armed. On the worker the lock screen was still lit 90 seconds after the lid opened. Before this change it stayed dark, which was the bug. Input wakes the panel and re-blanks it after five seconds.
  • Every lid open now runs omarchy-brightness-keyboard restore, which restores the level the last lock blank saved. If you change the keyboard backlight after unlocking and then close and reopen the lid while docked, nothing locks or saves on the way down. Opening it puts back the older level.

Waking through the lock screen when the session is locked, and running the clamshell reconciliation only when it is not, would avoid both. The lock screen has no IPC entry point for that today, though, so it is a design choice for the maintainer rather than a defect to patch here.

Related: #12210 also points lid open at omarchy-system-wake, as part of a larger change to how lid-close suspend works, and the two conflict on the same line. Codex Medium judged this one the more proportionate fix for #9628, agreeing with my own reading, though its independence is not guaranteed.

This is verified and waiting on the maintainer to decide whether those two side effects are acceptable as they stand.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the two outstanding review findings are non-blocking.

Findings

  1. P2 Lid open changes keyboard brightness ▶
  2. P2 Wake order goes untested ▶

Summary

The PR routes both standard and Apple SMC lid-open bindings through omarchy-system-wake, restoring brightness before reconciling clamshell monitor state. The tests check both bindings and the presence of the wake commands.

Reviews (2) · Last reviewed commit: "Merge quattro and wake the panel on an A..." · Reviewed by Greptile

o.bind("switch:on:Lid Switch", nil, "omarchy-system-lid-close", { locked = true })
o.bind("switch:off:Lid Switch", nil, "omarchy-hyprland-monitor-clamshell", { locked = true })
-- The lock screen powers the panel off after locking, so opening the lid has to wake it, not just reconcile clamshell.
o.bind("switch:off:Lid Switch", nil, "omarchy-system-wake", { locked = true })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Lid open changes keyboard brightness

When a docked laptop’s lid closes, it does not lock or turn off the keyboard backlight. Opening it now runs omarchy-system-wake, which restores a brightness value saved during an earlier lock. If the user changed the keyboard brightness since then, opening the lid overwrites their current setting.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +104 to +107
grep -F 'omarchy-brightness-display on' "$system_wake" >/dev/null
grep -F 'omarchy-brightness-keyboard restore' "$system_wake" >/dev/null
grep -F 'omarchy-hyprland-monitor-clamshell >/dev/null 2>&1 || true' "$system_wake" >/dev/null
pass "system wake resyncs clamshell display state"
pass "system wake restores display and keyboard brightness then resyncs clamshell"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Wake order goes untested

These checks only confirm that each command appears somewhere in the wake script. The test would still pass if the commands ran in a different order, despite claiming to verify that display and keyboard wake happen before clamshell reconciliation. An ordered assertion or a test using stubbed commands would catch that regression.

@niconistal

Copy link
Copy Markdown

One thing from real hardware that the VM repro can't show: after an actual suspend, a single omarchy-system-wake at lid open can lose a race with the lock screen.

On a MacBookPro14,3 (Omarchy 4.0.4, s2idle), I measured dpmsStatus once per second after an RTC-woken suspend while locked:

  • no lid-open action (quattro): 1 0 0 0 0 0 …. The display blanks about 1 s after resume and stays dark until input.
  • one omarchy-system-wake right at resume (this PR's approach): the display stayed dark until a second wake about 6 s later.
  • waking whenever the displays read off, every 0.5 s for the first 8 s: 1 0 1 1 1 1 …. That's lit from about +2 s on, and a webcam frame at +8 s shows the lock screen.

So the lock service's post-resume blank (the frozen idleBlankTimer, or the blank that happened before sleep) can land after the lid-open wake. Your fix works when the lid opens without a suspend, as in the uinput repro. After a real s2idle resume it needs either a short retry, or the lock service starting its fresh run-up instead of blanking when the resume coincides with a lid open. The retry I'm running locally:

displays_on() { hyprctl monitors -j | jq -e '[.[] | select(.disabled == false)] | length > 0 and all(.dpmsStatus)' >/dev/null; }
for _ in $(seq 1 16); do
  omarchy-hw-laptop-closed && exit 0
  displays_on || omarchy-system-wake >/dev/null 2>&1
  sleep 0.5
done

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 10, 2026
quattro added an Apple SMC lid switch beside the ACPI one, bound to the same clamshell-only command this branch replaces. The lock screen blanks the panel the same way on either machine, so both lid-open bindings now run omarchy-system-wake.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 11, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch no longer merged into quattro, so I pushed 693d54a, a merge of quattro (1b5222b) into it. The conflict came from #14431, which added an Apple Silicon lid switch (Apple SMC power/lid events) beside the ACPI one, bound to the same clamshell-only command this pull request replaces. The lock screen blanks the panel the same way on either machine, so the merge points both lid-open bindings at omarchy-system-wake, and monitor-recovery-test.sh checks both.

Re-run on an Omarchy worker at 693d54a. I locked the session, waited for the lock screen to turn DPMS off, then sent a lid close and open through a uinput device. I did this once under each switch name. On the head the panel comes back on. With the fix reverted, which leaves the bindings exactly as quattro has them, it stays off for both. ./test/cli passes, and so do monitor-recovery, lid-close, monitor-clamshell-scale and hw-laptop. The full shell suite fails the same tests here as on 1b5222b: the missing node on the worker, plus two logo tests. Reverting either binding makes monitor-recovery-test.sh fail.

@niconistal, thanks for measuring this on real hardware. I could not reproduce it on a worker, because a QEMU worker never comes back from s2idle. Codex Medium traced one path in the source that matches what you saw. If the machine suspends within the lock screen's 5-second run-up, idleBlankTimer (shell/plugins/lock/Service.qml:732) stays frozen until resume. On resume it sees the wall-clock gap and re-arms instead of blanking. Five seconds later it blanks, after the single wake from this binding has already run. Nothing in the binding cancels that countdown. This does not account for the blank about 1 s after resume in your quattro trace, so there may be a second cause. If the panel had already blanked before the machine slept, Codex found nothing that blanks it again after the wake. So this pull request fixes a lid open with no suspend, and probably some lid opens after suspend, but it is not proven to fix the after-suspend case #9628 describes. A retry loop, or a lid open that goes through the lock screen's own wake when the session is locked, are both design choices for the maintainer. Neither is a defect to patch here. The two side effects from the earlier review still stand: the lock screen stays lit after a lid open until there is input, and a docked close and reopen restores an older keyboard backlight level.

@BjornB2, since #9628 is yours, could you try this on the MacBook10,1? Run git clone https://github.com/basecamp/omarchy ~/omarchy-9637 && git -C ~/omarchy-9637 fetch origin pull/9637/head && git -C ~/omarchy-9637 checkout 693d54a08793bee80f8c99f9ca243141816890d4 && omarchy dev link ~/omarchy-9637, then reboot. Close the lid long enough for the machine to suspend, open it, and say whether the panel comes on by itself and stays on, or goes dark again a few seconds later. omarchy dev unlink puts you back.

Reviewed by Claude Opus 5.5, with Codex Medium as the second opinion on the merged head. Codex found the frozen-countdown path above and agreed that the merge resolution and the Apple SMC binding are right. Its independence is not guaranteed. This is verified for a lid open without suspend. It now waits on that test from @BjornB2, then on the maintainer's call on the side effects.

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

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lid-open binding does not restore display brightness after suspend

3 participants