Skip to content

Stop the DMI chassis fallback in omarchy-hw-laptop reading an empty string - #7948

Closed
chubuntuarc wants to merge 1 commit into
omacom:quattrofrom
chubuntuarc:hw-laptop-chassis-fallback
Closed

chubuntuarc wants to merge 1 commit into
omacom:quattrofrom
chubuntuarc:hw-laptop-chassis-fallback

Conversation

@chubuntuarc

Copy link
Copy Markdown

omarchy-hw-laptop falls back to the DMI chassis type when the machine exposes no ACPI lid button, but the fallback can never match. Bash only treats $(< file) as "read this file" when the substitution holds that one redirection and nothing else; adding 2>/dev/null turns it into a null command with two redirections, whose stdout is empty.

$ v=$(< /sys/class/dmi/id/chassis_type 2>/dev/null); printf '[%s]\n' "$v"
[]
$ v=$(< /sys/class/dmi/id/chassis_type); printf '[%s]\n' "$v"
[9]
$ v=$(cat /sys/class/dmi/id/chassis_type 2>/dev/null); printf '[%s]\n' "$v"
[9]

So the case always compares the empty string, and every laptop that reaches the fallback exits 1. On x86 the ACPI loop above answers first, which is what has kept this invisible: only hardware with no /proc/acpi at all falls through. Apple Silicon under Asahi is such a machine — hostnamectl chassis says laptop and /sys/class/dmi/id/chassis_type holds 9, yet omarchy-hw-laptop reports that this is not a laptop.

Everything gated on the command is silently off there. Laptop Display, Mirror Display, and Battery Percentage all carry "when": "omarchy-hw-laptop" in default/omarchy/omarchy-menu.jsonc, and omarchy-hyprland-monitor-watch:78 skips its omarchy-hw-laptop && omarchy-hyprland-monitor-external-active branch.

cat keeps the error suppression the original form was reaching for. After this change no $(< in the tree carries an extra redirection.

Tested on a MacBook Air M2 (J413) running Asahi Arch: bin/omarchy-hw-laptop goes from exit 1 to exit 0, matching hostnamectl chassis.

./test/all — 188 of 190 test files pass. The two failures, bar-icon-geometry-test.sh and snapper-test.sh, fail identically on a clean checkout on this machine and are unrelated to this change: a bar icon is painted 0.59 px off center, and the Snapper suite wants a sibling omarchy-iso checkout that isn't present.

Copilot AI balanced review requested due to automatic review settings August 23, 2026 19:00

Copilot AI left a comment

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.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@flip-in

flip-in commented Sep 6, 2026

Copy link
Copy Markdown

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

Same result as your M2 Air — bin/omarchy-hw-laptop goes from exit 1 to exit 0 with this change, against chassis_type 9 and hostnamectl chassis laptop. I hit this independently while chasing clamshell mode and reached the identical diagnosis before finding this PR; your write-up caught consequences I had missed, in particular the three omarchy-menu.jsonc entries, which are indeed absent here.

One thing worth having in the record for whoever triages this, because it is not visible from either PR alone: this fix and the omarchy-hw-laptop-closed fix are both required before clamshell works on Asahi, and neither is sufficient on its own.

That combination also produces a symptom that is confusing in isolation: patch only the lid state and the daemon reconciles against its own stale omarchy-hw-laptop answer, so a disabled internal panel visibly re-enables about a second later. It reads like the compositor fighting the config, but it is this helper.

Verified locally with both fixes applied, physical lid close while docked to an external display:

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 instead of flapping, and the session correctly neither locks nor suspends while docked. omarchy-hw-laptop returning true also restores Laptop Display, Mirror Display and Battery Percentage in the menu.

Filed #10477 for this before finding the PR; closing it as covered by this.

@cristim

cristim commented Sep 20, 2026

Copy link
Copy Markdown

Confirming this is still live on quattro today, and reproducing the gotcha directly on affected hardware.

Machine: MacBookPro17,1 (M1), Asahi, aarch64. No ACPI lid button, so the DMI fallback is the only branch that can answer.

$ printf '[%s]\n' "$(< /sys/class/dmi/id/chassis_type)"
[9]
$ printf '[%s]\n' "$(< /sys/class/dmi/id/chassis_type 2>/dev/null)"
[]
$ omarchy-hw-laptop; echo $?
1

chassis_type is 9 (Laptop) and reads fine, but adding 2>/dev/null takes the substitution off bash's $(<file) fast path and it expands empty, so the case matches nothing and the helper reports "not a laptop" on an actual laptop. $(cat ...) as proposed here fixes it.

Downstream effect, since the helper is a guard: omarchy-hyprland-monitor-watch:78 gates on it, and three omarchy-menu.jsonc entries are hidden by it (Laptop Display, Mirror Display, Battery Percentage), so those are silently unavailable on any machine without an ACPI lid button.

Worth noting this is a separate helper from omarchy-hw-laptop-closed and does not overlap #7951 / #9754: nothing in the lid-close or clamshell path gates on omarchy-hw-laptop, so this fix and those are independent and both needed.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified at 1ce5923; nothing found that needs changing.

Reproduced on an Omarchy worker VM, which has no ACPI lid button, with /sys/class/dmi/id/chassis_type bind-mounted to 9: omarchy-hw-laptop exits 1 on quattro, exits 0 with this change, and exits 1 again with the line reverted. With the VM's real chassis type (1) it still exits 1, so desktops are unaffected. ./test/cli passed (116 ok, 0 not ok), as did test/shell.d/monitor-modeless-test.sh and monitor-recovery-test.sh, which cover omarchy-hyprland-monitor-watch. No other $(< … 2>…) substitution remains in the tree.

Second opinion from Codex Medium agreed the bug is real and the fix is correct and proportionate (independence not guaranteed). It added one point worth recording: omarchy-hyprland-monitor-watch:78 will now start its reconciliation poll on lidless-ACPI laptops with an external monitor, but disabling the internal panel still requires omarchy-hw-clamshell, i.e. a lid actually reported closed, so this cannot turn off a panel on its own.

Waiting on the maintainer.

@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 ready Good to merge 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.

5 participants