omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Asahi MacBooks: lid handling can never fire — wrong switch name, and lid state read from /proc/acpi which Asahi lacks

Open GonzFC opened this issue 3 months ago • 5 comments

On Asahi MacBooks, Omarchy's lid handling can never fire — for two independent reasons. A closed lid does nothing at all: the panel stays lit indefinitely, and omarchy-system-lid-close never runs.

Tested on two MacBook Air M1s (Asahi, Omarchy 4.0 Quattro, omarchy-dev 4.0.0.r6560).

1. The switch bind targets a device name Apple hardware does not use

default/hypr/bindings/utilities.lua:

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 })

But hyprctl devices on these machines reports:

Switches:
	Switch Device at aaab301e2000:
		Apple SMC power/lid events

Lid Switch never matches, so neither bind fires.

2. omarchy-hw-laptop-closed reads a path Asahi does not provide

for state in /proc/acpi/button/lid/*/state; do
  [[ -r $state ]] || continue
  [[ $(< "$state") == *"closed"* ]] && exit 0
done
exit 1

Asahi has no ACPI. /proc/acpi/button/lid/ does not exist, so this always exits 1 — "lid is open", permanently. Even if the bind above fired, omarchy-system-lid-close would take no action, and omarchy-hw-clamshell can never be true.

The kernel does expose the switch, just not through ACPI:

$ cat /sys/class/input/input0/name
Apple SMC power/lid events
$ cat /sys/class/input/input0/capabilities/sw
1                     # bit 0 = SW_LID

Effect

With HandleLidSwitch=ignore in logind (as an always-on host wants), closing the lid leaves the internal panel at full backlight until some unrelated idle timer happens to fire — and never at all if anything keeps the session non-idle. Measured on this hardware: 6.61 W lid-closed-but-lit versus 1.66 W with the panel actually off.

Suggested fix

Two small changes, independent of each other:

  1. Match the lid switch by capability rather than by name — or bind both Lid Switch and the Apple name. Reading the device off hyprctl devices at config time also works.
  2. Give omarchy-hw-laptop-closed a non-ACPI fallback: find the input device whose capabilities/sw has bit 0 set and read SW_LID state from it, rather than assuming /proc/acpi.

Happy to open a PR for either or both if the shape sounds right — I have a working local implementation of the switch-name half.

GonzFC avatar Aug 26 '26 16:08 GonzFC

Confirming this on different hardware: MacBookPro18,3 (M1 Pro), Asahi, kernel 7.1.6-1-1-ARCH, Omarchy 4.0.2-mac.1 (omarchy-dev 4.0.2.r6875.g2afd2ef-1), Hyprland 0.56.1. Both causes reproduce exactly as described — hyprctl devices reports Apple SMC power/lid events, and /proc/acpi does not exist at all.

Two things to add.

There is a third, independent blocker

omarchy-hw-laptop is also broken here, and it is not Apple-specific — filed separately as #10477. Its DMI chassis fallback can never match, because $(< file 2>/dev/null) always expands to the empty string (bash's $(< file) fast path applies only when the substitution holds nothing but the redirect):

$ echo "[$(< /sys/class/dmi/id/chassis_type)]"
[9]
$ echo "[$(< /sys/class/dmi/id/chassis_type 2>/dev/null)]"
[]

This matters for this issue because omarchy-hyprland-monitor-watch gates its clamshell reconciliation poll on that helper:

if omarchy-hw-laptop && omarchy-hyprland-monitor-external-active; then

So on Asahi the 2s poll never starts. That is worth knowing while fixing this one: with the two helpers fixed, the poll engages clamshell on its own even without the bind fix — the bind fix then only makes it instant and gets omarchy-system-lock started early. It also explains a confusing symptom while testing: patch only the lid state and the daemon reconciles against its own stale view, so the internal panel visibly re-enables about a second after being disabled. Any fix has to be visible to that daemon, not just to the keybinding.

logind already knows the lid state

Rather than finding the input device with SW_LID and reading it directly: that node is root:input 0660, so it needs the user in the input group, which lets every process in the session read all input events. logind watches the same switch for its own HandleLidSwitch handling and publishes the answer:

[[ $(busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
       org.freedesktop.login1.Manager LidClosed 2>/dev/null) == "b true" ]]

As a fallback after the existing ACPI loop this keeps omarchy-hw-laptop-closed correct on both ACPI and non-ACPI machines, with no new dependency and no group change. (Docked is on the same interface if it is ever useful.)

Verified

Locally, with (1) that logind fallback, (2) $(cat …) in omarchy-hw-laptop, and (3) the two binds re-registered against Apple SMC power/lid events, a physical lid close while docked now does the right thing:

LidClosed: b true        omarchy-hw-laptop-closed: rc=0
Docked:    b true        omarchy-hw-clamshell:     rc=0
eDP-1 disabled=true      HDMI-A-1 disabled=false

eDP-1 holds off across the reconciliation passes rather than flapping, and the machine correctly neither locks nor suspends while docked. Opening the lid restores it within ~2s.

@GonzFC — if you are still up for the PR you offered, the busctl one-liner may be a simpler shape for the helper half than the evdev scan.

flip-in avatar Sep 06 '26 13:09 flip-in

Confirming on another Asahi machine: MacBookPro18,2 (M1 Max), kernel 7.1.13-3-2-ARCH, Omarchy 4.0.4-mac.1 — all three blockers still reproduce, and current main still ships only the generic switch:*:Lid Switch binds (no Apple-SMC name anywhere in the repo). /proc/acpi is absent; stock omarchy-hw-laptop-closed can never report closed; the omarchy-hw-laptop DMI fallback bug is still on main as well (tracked in PR #7948).

Verified working locally: busctl ... LidClosed shims for both hw helpers (per the suggestion above) + the two binds re-pointed at Apple SMC power/lid events — lid close disables eDP-1 and migrates workspaces to the external monitor; lid open restores the two-display layout.

One additional finding not yet in this thread: while the lid is closed, apple-spi-keyboard/apple-spi-trackpad keep emitting events — observed as stuck/repeating characters in focused apps. Gating both via hl.device({ name = "apple-spi-keyboard", enabled = false }) (same for apple-spi-trackpad) on lid close, re-enabled on open, fixed it. May be worth folding internal-input gating into the clamshell path alongside the display handling.

Filed by SWE-2 Max via Devin.

duketopceo avatar Sep 30 '26 16:09 duketopceo

Confirming the "daemon reverts the fix" half of this on MacBookPro18,2 (M1 Max), Omarchy 4.0.4-mac.1, kernel 7.1.13-3-2-ARCH — plus the mechanism that puts it out of reach of user-space fixes.

default/hypr/envs.lua rebuilds the PATH handed to spawned children with the omarchy bin dir force-prepended:

table.insert(kept, 1, bin_dir)
hl.env("PATH", table.concat(kept, ":"))

The watcher's own environment confirms it: /proc/<monitor-watch pid>/environ carries PATH=/usr/share/omarchy/bin:…:~/.local/bin:…. So inside sync_clamshell → omarchy-hyprland-monitor-clamshell → omarchy-hw-laptop-closed, the stock ACPI-only helper always wins over any ~/.local/bin shim and reports "lid open".

Observed on every close: the bind fires → omarchy-system-lid-close writes internal-monitor-clamshell.lua and disables eDP-1 → the disable itself emits monitorremoved → the watcher's sync_clamshell runs on that event → enable_internal → flag deleted, eDP-1 disabled=false again within ~1s. (The 2s poll never even starts here: stock omarchy-hw-laptop hits the $(< … 2>/dev/null) DMI bug from #10477, so sync_poll_state's gate fails — consistent with @flip-in's note that the poll doesn't run on Asahi.)

Consequence: with stock helpers the watcher isn't merely inert — it actively reverts clamshell state, so the panel stays powered inside the closed lid no matter what the binds do. Shims can fix the keybind path but can never reach the daemon's resolution, which makes the helper fixes load-bearing rather than cosmetic: #7951 (hw-laptop-closed via logind), #7948 (hw-laptop DMI), and #12693 (Apple-SMC bind name) together are what make a stock install clamshell-correct.

Verified workaround meanwhile: an hl.env("PATH") reorder in user config (evaluates after envs.lua, applies to deferred hyprland.start execs) restoring ~/.local/bin precedence, then restart the watch scope — the poll then starts, evaluates clamshell correctly, and enforces the disable: eDP-1 disabled=true held across ~50 min of poll cycles. Patches one machine's ordering only; the fix still belongs upstream.

Filed by SWE-2 Max via Devin.

duketopceo avatar Oct 03 '26 02:10 duketopceo

Closing as out of scope: Omarchy now supports only installs made from the official Omarchy ISO, and this report comes from Omarchy on Apple Silicon or Arch Linux ARM. A different base brings its own packages, kernel, boot setup and defaults, so we can't tell what here is Omarchy's to fix, and we aren't taking on fixes for setups the ISO doesn't produce. The community-maintained omarchy-mac project is the place for Apple Silicon. Thanks for the detailed report. If you can reproduce this on a fresh ISO install, say so here with the details and we'll reopen. (Checked by Claude Opus 5.5; no second review.)

omarchybot avatar Oct 08 '26 17:10 omarchybot

A follow-up for Apple Silicon: a fully supported Omarchy M Installer for Apple Silicon Macs is coming very soon. Once it ships, that will be the supported way to run Omarchy on these machines, and anything still wrong on an install made with it belongs in a new issue here.

omarchybot avatar Oct 08 '26 17:10 omarchybot