Skip to content

Ignore USB Touch Bar DRM when detecting external displays - #11516

Open
hanscnelson wants to merge 3 commits into
omacom:quattrofrom
hanscnelson:fix/hw-external-monitors-usb-touchbar
Open

hanscnelson wants to merge 3 commits into
omacom:quattrofrom
hanscnelson:fix/hw-external-monitors-usb-touchbar

Conversation

@hanscnelson

@hanscnelson hanscnelson commented Sep 12, 2026 •

Copy link
Copy Markdown

Summary

omarchy-hw-external-monitors walks /sys/class/drm/card*-*/status and treats every connected connector that is not eDP/LVDS/DSI as a desktop display.

On a T1 MacBook the Touch Bar is a real DRM device (card0-USB-1, always connected, ID_SEAT=seat-touchbar). Hyprland does not list it as a monitor. The helper still returned true with no HDMI/DP attached, so:

  • omarchy-system-lid-close skipped the lock (lid closed && ! external)
  • omarchy-hw-clamshell was true whenever the lid was shut
  • logind never took the undocked suspend path (HandleLidSwitchDocked=ignore)

Reproduced on MacBookPro14,2 (Omarchy 4.0.3, T1Bridge Touch Bar). With a local override of this helper, undocked lid-close locks immediately. A real DP/HDMI dock still counts.

This does not change lid-open bindings or suspend/resume backlight. A long lid-close that actually reaches S3 can still take a while to light the panel; that is separate.

Test plan

  • bash test/shell.d/hw-external-monitors-test.sh (existing cases plus USB-1 alone, split-card eDP+USB, DP still found with Touch Bar, HDMI still found)
  • bash test/shell.d/lid-close-test.sh
  • Live undocked lid-close on MacBookPro14,2: lock starts as soon as the lid shuts
  • Reviewer: USB-C DP-alt / DisplayLink still show up as DP-* / HDMI-* / DVI-*, not USB-*

Fixes #10618

T1/iBridge Touch Bar enumerates as card*-USB-* and stays connected. The helper treated that as a docked desktop, so undocked lid-close skipped the lock.
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 07e254f. The bug is real, and omarchy-hw-external-monitors is the right place to fix it. Excluding every USB connector is too broad, though: it also hides real external displays.

What was checked. On a disposable Omarchy worker I built fake DRM trees for the T1 layout in this PR (card1-eDP-1 + card0-USB-1) and the T2 layout in #10618 (card0-eDP-1 + card2-USB-2). The helper on quattro reports an external display for both. This head reports none. With the USB exclusion reverted, it reports one again. DP and HDMI next to a Touch Bar still count. hw-external-monitors-test.sh, lid-close-test.sh, monitor-recovery-test.sh and ./test/cli all pass on the worker. None of this ran on Touch Bar hardware, so the fix itself still needs confirming on a real machine. I've linked #10618, since this fixes it.

The finding. In the kernel, DRM_MODE_CONNECTOR_USB doesn't only mean the Touch Bar. The GUD driver uses it for USB panel displays and for any connector type it doesn't recognise (drivers/gpu/drm/gud/gud_connector.c). Asahi's Apple Silicon display driver uses it for USB-C outputs (drivers/gpu/drm/apple/dcp.c). Suppose one of those is the only external display and the lid is closed. bin/omarchy-system-lid-close:16 locks the session the user is working in. bin/omarchy-hw-clamshell:7 returns false, so bin/omarchy-hyprland-monitor-clamshell:248 re-enables the internal panel. bin/omarchy-hw-recover-internal-monitor:7 deletes the saved internal-monitor-disable toggle. My worker test confirmed the first step: a lone card3-USB-1 next to eDP-1 stops counting on this head. Keying the exclusion to the Touch Bar itself, not the connector type, would avoid this. On T2 that could be the appletbdrm driver, which also marks its connector non-desktop. On either chip it could be the Apple (05ac) USB device behind the card. You have the T1 machine to confirm which identity it exposes.

A correction to the description. logind doesn't consult this helper. It counts external displays itself, and only by type: VGA, DVI, DP, HDMI, TV and the like (src/login/logind-core.c). A USB connector was never on that list, so the Touch Bar never made logind treat the machine as docked. This PR fixes the immediate lock on lid close. It doesn't change the suspend path.

Related. #10713 fixes the same lock by switching omarchy-system-lid-close to Hyprland's monitor list, and #12682 carries that change. That approach leaves the other two callers above still seeing the Touch Bar. It also changes docked behaviour when a connected display is disabled in Hyprland. Fixing it in this helper covers every caller, which is why this is the one worth narrowing. Picking between them is the maintainer's call.

Second opinion. Codex at medium effort reviewed the diff pinned to this head. It raised the GUD and Asahi cases and the logind point, and I checked each against the kernel and systemd sources before including it here. It also reviewed the three competing PRs and preferred a narrowed version of this one. Its independence from my review isn't guaranteed.

Next. This is waiting on you to narrow the exclusion to the Touch Bar. After that, it needs confirming on Touch Bar hardware against the new head: @kutassy's T2 from #10618 as well as your T1.

@kutassy

kutassy commented Oct 1, 2026

Copy link
Copy Markdown

T2 data for #11516, from a MacBookPro15,2 (Omarchy 4.0.4-1, kernel 7.2.6-arch2-Watanare-T2-4-t2), no external display attached:

  • card2-USB-2 status connected. Every DP/HDMI connector on card1 is disconnected, but omarchy-hw-external-monitors still exits 0.
  • /sys/class/drm/card2/device is a USB interface bound to appletbdrm. Its parent USB device is 05ac:8302 ("Touch Bar Display", Apple Inc.), under t2bce_vhci.
  • modetest -M appletbdrm -c (as root) shows non-desktop = 1. But the helper runs as the desktop user (it's called from omarchy-system-lid-close, bound to the lid switch in Hyprland), and that user can't open /dev/dri/card2 here (root:video, no seat ACL, unlike card1). I couldn't find non-desktop anywhere in sysfs. So the helper can see the driver name and the USB vendor/product, but not that flag.
  • hyprctl monitors all lists only eDP-1.

Happy to test the narrowed head on this T2.

DRM_MODE_CONNECTOR_USB also covers GUD USB panels and other real displays, so excluding the connector type hid them as external monitors. The Touch Bar's card is backed by an Apple (05ac) USB device on both T1 and T2, and that vendor ID is readable by the desktop user, unlike the connector's non-desktop property. The vendor is read from the card's device or, when the driver binds an interface as appletbdrm does, from the interface's parent.

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

Copy link
Copy Markdown
Collaborator

I've pushed a33a609 to this branch. It narrows the exclusion so only the Touch Bar is ignored, not every USB connector. Thanks @kutassy, the T2 data is what made that possible.

What changed. omarchy-hw-external-monitors now skips a USB connector only when its card is backed by an Apple (05ac) USB device. It reads idVendor from the card's device, or from that device's parent when the driver binds an interface, as appletbdrm does. The desktop user can read that, which isn't true of the non-desktop flag. A GUD panel, or any USB connector it can't identify as Apple's, still counts as an external display. So a lone USB display with the lid closed no longer locks the session, re-enables the internal panel, or drops the saved disable toggle.

What was checked. I ran it on a disposable Omarchy worker against fake sysfs trees: the T1 layout from this PR (card0-USB-1), the T2 layout above (card2-USB-2 on an interface whose parent is 05ac), a driver bound to the whole USB device, DP and HDMI next to a Touch Bar, and a non-Apple GUD display. quattro fails the Touch Bar case. The previous head fails the GUD case. This head passes all 13 cases in hw-external-monitors-test.sh, and lid-close-test.sh, monitor-recovery-test.sh and ./test/cli pass too. None of it ran on Touch Bar hardware.

Second opinion. Codex Medium reviewed it in two rounds, pinned to the head each time. In the first round it pointed out that a driver bound to the whole USB device would put idVendor one level up from where the lookup read it, which is why it now checks both places. The second round, at this head, found nothing open. Its independence from my review isn't guaranteed.

Next. This needs confirming on real Touch Bar hardware at this head. @kutassy (T2) and @hanscnelson (T1), could you run it as your desktop user, with no external display attached?

curl -fsSL https://raw.githubusercontent.com/hanscnelson/omarchy/a33a609869e82ccef6a645186b5163037338aab1/bin/omarchy-hw-external-monitors -o /tmp/hw-external-monitors
bash /tmp/hw-external-monitors; echo $?

It should print 1, and 0 once a DP or HDMI display is plugged in. On the T1, closing the lid with nothing attached should lock straight away once this helper is the one installed. #10713 and #12682 remain the competing approaches. Choosing between them is still the maintainer's call.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The PR excludes Apple USB Touch Bar connectors from external-monitor detection while keeping other connected displays eligible.

  • The external-monitor check skips the Apple Touch Bar but still counts real displays.

Reviews (2) · Last reviewed commit: "Merge quattro and move the Touch Bar tes..." · Reviewed by Greptile

@kutassy

kutassy commented Oct 1, 2026

Copy link
Copy Markdown

Tested a33a609 on the MacBookPro15,2 (T2), as the desktop user, no external display attached:

$ bash /tmp/hw-external-monitors; echo $?
1

The installed 4.0.4 helper returns 0 on the same machine. The trace shows touch_bar matching on the parent device's idVendor = 05ac.

One correction to my earlier data: the card index isn't stable. appletbdrm re-initialises on every resume from suspend, alternating between minor 0 and minor 2 (eight consecutive resumes in the last week went 2, 0, 2, 0, …). So the Touch Bar is card2-USB-2 or card0-USB-1 depending on how many suspends there have been since boot. The new helper doesn't depend on the index, so it handles both.

I haven't tested the DP/HDMI-attached case yet. I'll follow up with that once I can dig out an external monitor.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @kutassy. That T2 result is the confirmation this fix was waiting on, and your note on the alternating card index matters too: the helper finds the card from each connector's name every time it runs, so card0-USB-1 and card2-USB-2 are both handled.

What was checked at a33a609. On a fresh disposable Omarchy worker, against quattro at 8b4eae6: with a T2-shaped sysfs tree (card2-USB-2 on an interface whose parent is 05ac, no external display), the quattro helper reports an external display, this head does not, and with the helper change reverted it reports one again. hw-external-monitors-test.sh (13 cases), lid-close-test.sh, monitor-recovery-test.sh and ./test/cli all pass. Codex Medium reviewed this head again with your result in hand and found nothing open. It agreed the change is proportionate and that a T1 Touch Bar not on an Apple USB device would be left as it is on quattro, not made worse. Its independence from my review isn't guaranteed. Claude Opus 5.5 did the first review.

What's left. The record that marks a fix verified needs the confirmation to name the full commit, and your comment says a33a609. When you follow up with the DP/HDMI-attached case, could you include a33a609869e82ccef6a645186b5163037338aab1 in that comment? With a display plugged in, the helper should print 0. @hanscnelson, a result from the T1 at the same commit would show whether it covers that machine too. #10713 and #12682 are still the competing approaches, and choosing between them is the maintainer's call.

@kutassy

kutassy commented Oct 3, 2026

Copy link
Copy Markdown

Tested a33a609 with an external display attached (MacBookPro15,2 / T2, Omarchy 4.0.4). HDMI EDID dummy plug (1920×1080@60) via an Apple USB-C Digital AV Multiport Adapter (A1621):

card0-USB-1   connected     # Touch Bar
card1-eDP-1   connected
card1-DP-2    connected     # external

New helper exits 0; Hyprland shows eDP-1 + DP-2. Combined with the earlier no-display run (exit 1), the Touch Bar is ignored and real external outputs are still detected — including behind an Apple (05ac) USB-C adapter, since that output appears as a DP connector on the iGPU rather than a USB one.

Happy to repeat with a physical monitor if you'd prefer.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @kutassy. The attached-display run closes the other half: with the Touch Bar on card0-USB-1 and an HDMI dummy plug on card1-DP-2, the helper exits 0, and with nothing attached it exits 1. That is the behaviour this fix is after on a T2, including behind an Apple USB-C adapter, which shows up as a DP connector on the iGPU and not as a USB one.

One thing still missing. A hardware fix is recorded as verified only from a confirmation that names the full commit, and both of your results say a33a609. A one-line reply is enough, e.g. "Confirmed on MacBookPro15,2 at a33a609: exits 1 undocked, 0 with DP attached." Please post it as a new comment rather than editing an earlier one. The head hasn't moved since the worker run and review described above, so nothing else needs repeating.

Competing fixes. Claude Opus 5.5 and Codex Medium each compared this PR with #10713 and #12682, Codex without seeing my answer. Both preferred this one. The other two change only the lid-close lock, so omarchy-hw-clamshell and omarchy-hw-recover-internal-monitor still count the Touch Bar as an external display, and the recovery path can leave the internal panel's disable toggle in place after a real monitor is unplugged. That recommendation goes to the maintainer, who makes the choice. Codex's agreement with me is not guaranteed to be independent.

Next. This is waiting on the full-SHA confirmation above. After that, it's the maintainer's decision.

@kutassy

kutassy commented Oct 7, 2026

Copy link
Copy Markdown

Confirmed on MacBookPro15,2 (T2, Omarchy 4.0.4) at a33a609: exits 1 undocked, 0 with DP attached.

@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 7, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks @kutassy. That confirmation names the full head, a33a609, so this fix is now recorded as verified: the T2 Touch Bar no longer counts as an external display, and a real DP output still does.

What was checked. The head hasn't moved since the worker run described above (a T2-shaped sysfs tree reproduces the bug on quattro, passes on this head, and fails again with the helper change reverted, and the suite passes on the worker). Codex Medium read your new comment against this head and found nothing open, as did Claude Opus 5.5. Codex's agreement with my review isn't guaranteed to be independent.

Next. Nothing is left for the author. This is waiting on the maintainer, who also chooses between this and the competing approaches in #10713 and #12682. A T1 result from @hanscnelson at the same commit would still be welcome, but it isn't blocking.

@hanscnelson

Copy link
Copy Markdown
Author

Confirmed on MacBookPro14,2 (T1, Omarchy 4.0.4, undocked) at a33a609: the helper exits 1. card0-USB-1 is connected, DP and HDMI are disconnected, and Hyprland lists only eDP-1. No external display was attached for this run.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 28, 2026
quattro folded hw-external-monitors-test.sh into hw-display-test.sh (omacom#16337), so the Touch Bar cases move there. Three of the eight are dropped as covered by the rest: the standalone and T1 interface-bound Touch Bar cases exercise the same interface lookup as the T2 case, and a disconnected Touch Bar beside HDMI was already ignored by the status check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This stopped merging after #16337 deleted test/shell.d/hw-external-monitors-test.sh and folded its cases into test/shell.d/hw-display-test.sh. I merged quattro into the branch (78190a2) and moved your Touch Bar cases into hw-display-test.sh. bin/omarchy-hw-external-monitors is exactly as you left it.

I kept five of the eight cases: a T2 Touch Bar bound at its USB interface, a Touch Bar bound to the whole USB device, DP beside a Touch Bar, a non-Apple GUD USB display, and a USB connector with no device behind it. I dropped three because other cases already exercise the same paths. The standalone and T1 interface-bound Touch Bar cases use the same interface lookup as the T2 case, and a disconnected Touch Bar beside HDMI was already skipped by the status check.

I ran these on a worker built from the Omarchy ISO. With the fix reverted, the T2 case fails. At this head, hw-display-test.sh passes 22 of 22. ./test/cli passes, as do lid-close-test.sh, monitor-clamshell-scale-test.sh and monitor-recovery-test.sh, the tests for the scripts that call this helper. Your fix itself was confirmed on a MacBookPro15,2 at a33a609 and by you on a MacBookPro14,2. Since the merge left the fix unchanged, I did not ask for another hardware run.

Codex Medium and muse-wonder (pi, thinking high) reviewed the merge and the fix and found no defects. Both said the dropped cases leave no gap and that GUD, DisplayLink and DP-alt displays still count as external. That is agreement, and independence is not guaranteed.

#14994 still competes with this. Earlier triage picked this one because it came first and has no defect that #14994 avoids, and neither pull request has changed since. One small thing for you: the description still names hw-external-monitors-test.sh, which no longer exists.

This is now waiting on the maintainer.

@hanscnelson

Copy link
Copy Markdown
Author

Omarchy 4.5.0-3 (tag v4.5.0) still ships the helper without the Apple USB skip. bin/omarchy-hw-external-monitors at that tag has no 05ac check, and the last commit that touched it on the tag is from August.

The package update replaced a locally installed copy of a33a609 on this MacBookPro14,2. Undocked, the 4.5 helper exits 0: card0-USB-1 is connected, and DP and HDMI are disconnected. Head 78190a2 is not in the 4.5.0 package.

This is the lock-classification bug. The dark strip after S3 on the same update is t1bridge 0.1.12, reported on standardagents/t1bridge#18.

@kutassy

kutassy commented Nov 9, 2026

Copy link
Copy Markdown

Retested on head 78190a230e7fc7b455f49567282adc205d964fbe on a T2 MacBook Pro (Touch Bar on appletbdrm, USB 05ac), installed package omarchy 4.5.0-3, run as a normal user:

  • Internal display only: connected outputs are card1-eDP-1 and card0-USB-1 (Touch Bar), with every DP/HDMI port disconnected. The PR helper exits 1. The installed 4.5.0-3 helper exits 0, so the bug still reproduces on 4.5.0-3.
  • HDMI EDID dummy (1920×1080@60) via Apple A1621 adapter: card1-DP-2 connected, Touch Bar still connected. The PR helper exits 0, and so does the installed one. Hyprland shows eDP-1 + DP-2.

Same results as on a33a609. The PR fixes the false positive on this machine and still detects a real external display.

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

omarchy-hw-external-monitors false positive from tiny-dfr Touch Bar DRM device causes lid-close lock to silently fail (T2 Macs)

3 participants