Skip to content

fix(hypr): bind the lid switch by its Apple Silicon device name too - #12693

Closed
cristim wants to merge 2 commits into
omacom:quattrofrom
cristim:fix/lid-bind-matches-apple-switch
Closed

cristim wants to merge 2 commits into
omacom:quattrofrom
cristim:fix/lid-bind-matches-apple-switch

Conversation

@cristim

@cristim cristim commented Sep 20, 2026

Copy link
Copy Markdown

default/hypr/bindings/utilities.lua binds the lid to the device name Lid Switch. Apple Silicon reports its lid as Apple SMC power/lid events, so neither bind matches and omarchy-system-lid-close never runs on that hardware.

Hyprland matches a switch bind by exact string comparison and has no wildcard form. Checked against the v0.56.2 tag:

  • CInputManager::newSwitch passes the raw device name to onSwitchOnEvent / onSwitchOffEvent.
  • onSwitchOnEvent builds keyName = "switch:on:" + switchName verbatim, with no normalization.
  • handleKeybinds compares with if (key.keyName != k->key) continue;, a plain std::string inequality. No prefix, substring, or case folding.
  • There is no "any switch" form. switch:on: with an empty name is just another literal, and the catchAll branch is gated on key.keyName.empty(), which never holds for a switch event.
  • Aquamarine does expose AQ_SWITCH_TYPE_LID, but Hyprland's fire listener reads only event.enable, so capability matching is not available either.

A second literal pair is therefore the only fix available in this version. Registering both is safe: handleKeybinds evaluates every bind independently, and only one of the two names can equal a given machine's device name, so exactly one pair fires.

Hardware

MacBookPro17,1 (M1, 2020), Arch Linux ARM, Hyprland 0.56.2.

$ hyprctl devices -j | jq -c '.switches'
[{"address":"0xaaab35433e80","name":"Apple SMC power/lid events"}]

What this does and does not change

It does not fix "closing the lid fails to lock", because logind sees the lid through its own evdev handling and already covers that. Measured on this machine:

22:27:56 systemd-logind: Lid closed.
22:27:56 systemd-logind: Suspending...
22:27:57 kernel: PM: suspend entry (s2idle)

What is missing is omarchy's own lid handling. Since the bind never fires, omarchy-system-lid-close never runs, so its docked exemption ("a docked lid close does not suspend, so it must not lock either") never applies, and omarchy-hyprland-monitor-clamshell never runs on lid open.

This is one of the two independent breakages described in #8418. The other is omarchy-hw-laptop-closed reading /proc/acpi, which Apple Silicon does not provide; that half is addressed by #7951 and #9754. Both are needed before a lid close reaches omarchy-system-lock through omarchy's own path.

Test plan

  • bash test/shell.d/lid-switch-bindings-test.sh, new here. Asserts both device names bind on and off to the same handlers with locked = true, which matters because without it the bind is skipped exactly when the lid closes on an already locked session. Verified to fail against the pre-fix file and pass after.
  • bash test/shell.d/hyprland-binding-conflicts-test.sh, the added binds introduce no conflict.
  • bash test/shell.d/hyprland-default-config-test.sh
  • bash test/shell.d/lid-close-test.sh

Refs #8418

🤖 Generated with Claude Code

Hyprland compares a switch bind against the device name byte for byte and
0.56 has no wildcard form, so a lid reporting any other name never fires.
Apple Silicon exposes its SW_LID switch as "Apple SMC power/lid events",
never as "Lid Switch", so neither lid bind matched and
omarchy-system-lid-close never ran on that hardware.

Refs omacom#8418
@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

No actionable defect found in the source review at 702530322ada.

Verified (source inspection): The added Apple-name bindings retain the existing Lid Switch pair, use the same handlers, and preserve locked = true. Omarchy passes the key string unchanged to hl.bind; the inspected Hyprland v0.56.2 parser preserves the Apple name and its switch-event matcher compares it exactly.

Switch name Base PR
Lid Switch Close/open handlers registered Unchanged
Apple SMC power/lid events No matching pair Same close/open handlers registered

This fixes the registration gap, not the complete Apple lid-handling path: omarchy-hw-laptop-closed still relies on /proc/acpi, so the separate non-ACPI lid-state fix remains necessary for the described Asahi setup.


Review information

Test scope: Source inspection only, including the new literal-binding test. No tests or physical lid events were executed; locking, suspend and display behavior on Apple hardware were not independently verified.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium initial inspection and synthesis, independent Opus 5.5 High and GPT 6 Sol Xhigh technical reviews, with claims checked against source evidence and a fresh Astra Medium editorial check.

@omarchybot omarchybot added bug Something isn't working compatibility Make Omarchy work better on everything! labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 702530322ada13dfa5e962640b6fcaec22d6ebd4 against quattro; nothing found wrong in the change. It waits on a hardware confirmation from @GonzFC, who reported this in #8418.

What ran, on a disposable Omarchy VM (Hyprland 0.56.2):

  • Linked into the live session, the head registers switch:on:Apple SMC power/lid events and switch:off:Apple SMC power/lid events with locked = true and the same handlers as Lid Switch, with no config errors. The Lid Switch pair is unchanged. The base (45748a28) registers only the Lid Switch pair.
  • test/shell.d/lid-switch-bindings-test.sh fails against the base file (the Apple pair is missing) and passes on the head.
  • ./test/cli passes. The full test/shell.d suite has three failures (ascii-test.sh, branding-about-animation-test.sh, omarchy-kernel-migration-test.sh), and screenshot-sanity-test.sh exits non-zero. All four fail the same way on the base, so none come from this change.

The VM has no lid switch, so this proves the bind is registered, not that it fires on Apple hardware. A bind for a device name a machine doesn't have does nothing, so other laptops are unaffected.

On its own this has no visible effect on Apple Silicon. As the description says, omarchy-system-lid-close locks only when omarchy-hw-laptop-closed reports the lid closed. That check reads /proc/acpi, which Asahi doesn't have, so the bind fires and then does nothing until #7951 (still open; #9754 was closed) lands as well. This is why it doesn't claim to close #8418.

Same change elsewhere: #13661 adds the same two binds to the same file on the same base, and was opened later. This one is the more complete of the two, because its test also checks locked = true. Choosing between them is the maintainer's call. #13370 is about a wrong Apple bind in the omarchy-mac fork's copy of this file, not about upstream.

Second opinion: none. The configured reviewer (Codex Medium) answers, but today's review budget was used up, so only Claude Opus 5.5 reviewed this.

@GonzFC, if you can, please test this exact commit on one of your MacBook Airs:

git clone https://github.com/cristim/omarchy.git ~/omarchy-12693
git -C ~/omarchy-12693 checkout 702530322ada13dfa5e962640b6fcaec22d6ebd4
omarchy dev link ~/omarchy-12693

After the reboot, hyprctl binds -j | jq -c '.[] | select(.key | startswith("switch:"))' should list the Apple pair. To see the bind fire, run inotifywait -m -e open ~/omarchy-12693/bin/omarchy-system-lid-close ~/omarchy-12693/bin/omarchy-hyprland-monitor-clamshell (from inotify-tools), then close and reopen the lid. Closing should open omarchy-system-lid-close, and opening should open omarchy-hyprland-monitor-clamshell. omarchy dev unlink puts things back.

@cb2206

cb2206 commented Oct 8, 2026

Copy link
Copy Markdown

Hardware confirmation from a 14" MacBook Pro (M1 Pro, 2021, apple,j314s), Hyprland 0.56.2. I ran omarchy-mac 4.0.3rc4, which has exactly these two bind lines, and an omarchy-hw-laptop-closed that reads logind's LidClosed first, as #7951 does.

$ hyprctl devices -j | jq -c .switches
[{"address":"0xaaabc7147ee0","name":"Apple SMC power/lid events"}]

I traced the lock state (omarchy-shell lock status), the running lid scripts and logind's signals at 100 ms intervals:

  1. Lid close, logind held off (systemd-inhibit --what=handle-lid-switch), so only the bind can act. omarchy-system-lid-close was running 68 ms after Lid closed, the lock was requested at +206 ms and was secure at +1.2 s, with no suspend.
  2. Lid close with normal suspend. The session was secure at +1.2 s, 0.3 s before PM: suspend entry (s2idle). After resume the lock screen was up at once.
  3. Docked lid close (LG UltraFine 5K over Thunderbolt). omarchy-system-lid-close ran with no lock and no suspend (Docked=true), and eDP-1 was turned off within 0.35 s. Its workspace moved to the external display, and on lid open eDP-1 came back with it.

So the device name is right, and with this PR plus #7951 both the lock and the clamshell path work on Apple Silicon.

The test checked each bind with a substring match, so it still passed with every lid bind commented out, which is the regression it exists to catch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed now that a second opinion was available. Codex Medium found a defect in the new test, so I pushed a fix to the branch. The new head is 428f61505cea10bc9451cd5813354b0ec237c261. The bind change itself is unchanged, and nothing was found wrong with it.

What was wrong: test/shell.d/lid-switch-bindings-test.sh looked for each bind with utilities.includes(bind), a substring match. A bind that was commented out still matched. On a disposable Omarchy VM, the old test passed with all four switch: binds commented out. It now requires each bind to appear as a whole line after trimming, as the test's own comment says it should. On the VM, the fixed test fails on that file, fails against the base utilities.lua (the Apple pair is missing there), and passes on the head. ./test/cli, hyprland-binding-conflicts-test.sh, hyprland-default-config-test.sh and lid-close-test.sh pass.

Codex also pointed out two cases a line match can't handle: binds wrapped in a --[[ ]] block comment still pass, and a bind with a trailing -- comment fails. Covering those properly means rewriting the test to load the Lua with a stubbed hl.bind, the way hyprland-binding-conflicts-test.sh does. That's a bigger change to your test than the defect called for, so I've left that choice to the maintainer.

Who checked it: Claude Opus 5.5 and Codex Medium. Codex agreed the bind change is correct and proportionate. It also confirmed that o.bind passes the device name through unchanged on both the PR's base and current quattro, and that Lid Switch laptops are unaffected. That part is agreement, and its independence isn't guaranteed. The test defect was Codex's own finding.

Hardware confirmation: @cb2206, thanks for the detailed trace on the M1 Pro. It's strong evidence that the device name is right and that this PR plus #7951 makes both the lock and the clamshell path work, and the maintainer can weigh it. It can't mark this PR verified, though. That needs a test of this exact commit, by the person who reported #8418 or by a maintainer, and your run used omarchy-mac's copy of these lines.

#13661, which added the same binds, has since been closed, so this PR has no competitor. Lock on lid close on Apple Silicon still also needs #7951, which is still open.

@GonzFC, if you can, please test the new head on one of your MacBook Airs:

git clone https://github.com/cristim/omarchy.git ~/omarchy-12693
git -C ~/omarchy-12693 checkout 428f61505cea10bc9451cd5813354b0ec237c261
omarchy dev link ~/omarchy-12693

The checks are the same as in my earlier comment. After the reboot, hyprctl binds -j | jq -c '.[] | select(.key | startswith("switch:"))' should list the Apple pair. While inotifywait -m -e open ~/omarchy-12693/bin/omarchy-system-lid-close ~/omarchy-12693/bin/omarchy-hyprland-monitor-clamshell is running, closing the lid should open the first file and opening it should open the second. omarchy dev unlink puts things back.

@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds lid-switch bindings for Apple Silicon devices.

The PR appears safe to merge; no actionable issue was found.

What we checked:

  • Device names stay unchanged: o.bind passes keys and the supplied options directly to hl.bind.
  • The new test is discovered: test/shell includes every *-test.sh file except base-test.sh, so it includes the added file.

Summary

Adds lid-close and lid-open bindings for Apple Silicon’s Apple SMC power/lid events device.

  • Keeps the existing Lid Switch bindings and uses the same handlers for both names.
  • Allows both pairs to fire while the session is locked.
  • Adds a test that checks the exact device names, handlers, and locked options.

Reviews (1) · Last reviewed commit: "Match lid binds as whole lines, so a com..." · Reviewed by Greptile

@omarchybot

Copy link
Copy Markdown
Collaborator

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

@omarchybot omarchybot closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working compatibility Make Omarchy work better on everything!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants