Repository navigation
Stop counting Hyprland's virtual outputs as external monitors - #8028
HritwikSinghal wants to merge 1 commit into
Conversation
Disabling the laptop panel while docked and then unplugging the external display left the laptop with no display at all until the next login. Hyprland's FallbackStateKeeper (src/state/FallbackState.cpp, since 0.56.0) creates an output named literally FALLBACK the moment the set of ENABLED monitors becomes empty. ENABLED is the part that bites: it watches `monitors()`, not `allMonitors()`, so an internal panel sitting at `disabled = true` does not stop it firing. Unplugging the external display in that state therefore leaves exactly one monitor -- a virtual one that reports disabled=false and whose name matches none of the internal-panel prefixes. omarchy-hyprland-monitor-external-active asked only about names, so it answered "an external monitor is active", and every caller that uses it to decide whether re-enabling the internal panel is safe backed off: omarchy-hyprland-monitor-internal's recover(), omarchy-hyprland-monitor-clamshell's enable_internal(), and the watcher's clamshell poll. The monitorremoved retries at 1s, 3s and 7s all bailed at the same line. Only the next login recovered it, because omarchy-recover-internal-monitor.service asks omarchy-hw-external-monitors instead -- and that one reads DRM state, which cannot be fooled this way. Ask the kernel too: a real display has a DRM connector, a virtual output has none. This restores the hardware truth 96afc68 deliberately moved recovery onto ("Move to a hardware check for external monitors instead to deal with recover timing") and which recover() lost when it moved back onto this helper. `monitors all` stays, so a mirrored external -- absent from plain `monitors`, and a real display with a connected connector -- keeps counting. The new test fails on the old helper at its first assertion.
There was a problem hiding this comment.
Pull request overview
Prevents Hyprland virtual outputs from being mistaken for physical external monitors by validating active outputs against DRM connectors.
Changes:
- Cross-checks Hyprland outputs with connected DRM hardware.
- Adds coverage for virtual, mirrored, disabled, internal, and external displays.
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 no comments.
| File | Description |
|---|---|
bin/omarchy-hyprland-monitor-external-active |
Filters active outputs through DRM connection status. |
test/shell.d/monitor-external-active-test.sh |
Tests virtual-output regressions and existing monitor behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
closed in favor of #7036 |
|
Please reopen. Closing this in favor of #7036 was a mix-up — they are different bugs. #7036 is the Display panel ( This PR is the one that stops Hyprland's virtual Confirmed again on 2026-09-14, Omarchy |
|
tracked here now #12616 |
Fixes #8027. Likely also #7228 and #7209.
The bug
Disable the laptop panel while docked, unplug the external display, and the laptop is left with no display at all until the next login.
Hyprland's
FallbackStateKeeper(src/state/FallbackState.cpp, since 0.56.0) creates an output named literallyFALLBACKthe moment the set of enabled monitors becomes empty. Enabled is the part that bites: it watchesmonitors(), notallMonitors(), so an internal panel sitting atdisabled = truedoes not stop it firing. Unplugging the external display in that state therefore leaves exactly one monitor -- a virtual one, reportingdisabled: false, whose name matches none of the internal-panel prefixes.omarchy-hyprland-monitor-external-activeasked only about names, so it answered "an external monitor is active", and every caller that uses it to decide whether re-enabling the internal panel is safe backed off:omarchy-hyprland-monitor-internal'srecover(),omarchy-hyprland-monitor-clamshell'senable_internal(), and the watcher's clamshell poll. Themonitorremovedretries at 1s, 3s and 7s all bailed at the same line.Only the next login recovered it, because
omarchy-recover-internal-monitor.serviceasksomarchy-hw-external-monitorsinstead -- and that one reads DRM state, which cannot be fooled this way.The fix
Ask the kernel too: a real display has a DRM connector, a virtual output has none.
This restores the hardware truth 96afc68 deliberately moved recovery onto ("Move to a hardware check for external monitors instead to deal with recover timing") and which
recover()lost when it moved back onto this helper. omarchy 3.8.5 guardedrecover()onomarchy-hw-external-monitorsand was immune.Fixing the helper rather than each caller corrects
recover(),off(),clamshell'senable_internal()/disable_internal()and the watcher's poll in one place.monitors allstays, so a mirrored external -- absent from plainmonitors, and a real display with a connected connector -- keeps counting. That case is pinned in the new test.OMARCHY_DRM_PATHis honoured for the same reasonomarchy-hw-external-monitorshonours it: the tests point it at a fixture tree.Tests
New
test/shell.d/monitor-external-active-test.sh, 9 assertions. It stubshyprctland builds a fixture DRM tree, followinghw-external-monitors-test.shandmonitor-clamshell-scale-test.sh.It covers the two regressions (
FALLBACK,HEADLESS-n) and pins the behaviour the helper already had so the sysfs cross-check cannot quietly take it away: a connected external, a mirrored external, an external disabled on purpose, the internal-panel prefixes, external-only systems, an unansweredhyprctl, and an internal-only session.Against the current helper it fails at its first assertion:
With the fix, all 9 pass. The existing
grepassertions on this helper inmonitor-recovery-test.shstill pass unchanged.Full suite: 187 of 191 files pass. The 4 that fail (
agent-usage-claude-scanner,config,snapper,unowned-system-paths) fail identically on a pristinequattrocheckout -- see #7125.Verifying by hand, without unplugging anything