Repository navigation
Read the lid from logind so clamshell works without an ACPI lid button - #7951
chubuntuarc wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Uses logind’s evdev-backed lid state to support clamshell detection on hardware without ACPI lid files.
Changes:
- Queries logind before falling back to ACPI.
- Adds shell tests for open and closed logind responses.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-hw-laptop-closed |
Adds logind-based lid detection. |
test/shell.d/hw-laptop-closed-test.sh |
Tests logind lid responses and preserves the ACPI fallback. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Nothing else in the tree can stand in for logind here, so a machine whose | ||
| # logind cannot answer has to keep reaching the ACPI button this command has | ||
| # always read. | ||
| grep -F '/proc/acpi/button/lid/*/state' "$hw_laptop_closed" >/dev/null || | ||
| fail "the ACPI lid button stays as the fallback" | ||
| pass "the ACPI lid button stays as the fallback" |
|
Confirming this on a second Asahi machine, a different model and SoC generation from the M2 Air in the description. MacBookPro17,1 (M1, 2020), Arch Linux ARM, kernel 7.1.13-2-1-ARCH, omarchy 4.0.3-mac.1.
Scope of what I tested: I confirmed the open-lid reading and that logind responds. I did not capture a lid-closed sample on this machine, so I am not independently confirming the One thing worth flagging for whoever merges thisOn this hardware the helper is not the only broken half. 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 })and
Overlap with #9754#9754 rewrites the same command and adds the same new test file, so the two conflict and only one can land. The substantive differences, in case it helps pick:
|
|
Reviewed at What ran, on a disposable Omarchy VM: a reproduction of my own that stubs logind's reply and fakes an ACPI lid by mounting a tmpfs over Second opinion (Codex Medium): it found two things I had not reasoned about. I checked both against systemd v262's source, and both hold. Neither is a reason to hold this back, and neither has a fix that isn't a design choice, so I have pushed nothing:
The rest of its review agreed with mine, and this agreement shouldn't be counted as independent: it found the test non-vacuous, the fix proportionate, and nothing that regresses on desktops, lidless VMs or ACPI laptops with a working lid. Linked: this now closes #9753 on merge. It fixes one of the two causes in #8418. The Hyprland bind in Waiting on: a confirmation on the affected hardware at this exact commit. @GonzFC (#8418, Asahi) or @bbishdotdev (#9753, stale ACPI), could you run this on your machine? Run it once with the lid open, which should print |
|
Closing as out of scope: Omarchy now supports only installs made from the official Omarchy ISO, and this change exists for Apple Silicon, which the ISO doesn't produce. We aren't taking on code paths for setups outside that, because nobody here can test or maintain them. The community-maintained omarchy-mac project is the place for Apple Silicon work. Thanks for the work that went into this. (Checked by Claude Opus 5.5; no second review.) |
omarchy-hw-laptop-closedreads the lid from/proc/acpi/button/lid/*/state. Hardware without an ACPI lid button has no such file — Apple Silicon has no/proc/acpiat all — so the glob matches nothing and the command reports the lid open forever. logind tracks the lid through evdev'sSW_LID, which answers on that hardware, so ask it first and keep the ACPI button as the fallback.That stale answer is load-bearing in three places:
omarchy-hw-clamshellisomarchy-hw-laptop-closed && omarchy-hw-external-monitors, so clamshell mode never engages:omarchy-hyprland-monitor-clamshelltakes itsenable_internalbranch with the lid shut and leaves the internal panel driving while docked.omarchy-system-lid-closegates the lock on it, so a lid close never locks early and always waits for logind'sPrepareForSleepinstead — the head start its own comment describes cannot happen.pam_exec.so quiet /usr/bin/omarchy-hw-laptop-closedin the polkit PAM config andfingerprintMode: … && !laptopClosedinshell/plugins/polkit/PolkitAgent.qmlboth keep offering the reader when the lid it sits under is closed.busctl get-propertyis the same idiomomarchy-powerprofiles-setalready uses for UPower'sOnBattery, and four commands inbin/callbusctl, so this adds no new dependency. Only the command changes here; #7871's work on the same lid gate touches the PAM config side, so the two diffs don't overlap.Verified on a MacBook Air M2 (J413) running Asahi Arch, where
/proc/acpidoes not exist:test/shell.d/hw-laptop-closed-test.shstubs logind's two answers, asserts the exit codes the callers branch on, and asserts the ACPI fallback stays. It fails against the current command — the closed lid exits 1 — and passes against this one../test/all— 189 of 191 test files pass.bar-icon-geometry-test.shandsnapper-test.shfail identically on a clean checkout on this machine and are unrelated: a bar icon painted 0.59 px off center, and a missing siblingomarchy-isocheckout.bar-widget-contract-test.shflaked once during a full run and passes both in isolation and on re-run.Fixes #9753