Skip to content

Stop counting Hyprland's virtual outputs as external monitors - #8028

Closed
HritwikSinghal wants to merge 1 commit into
omacom:quattrofrom
HritwikSinghal:fix/external-active-ignores-virtual-outputs
Closed

HritwikSinghal wants to merge 1 commit into
omacom:quattrofrom
HritwikSinghal:fix/external-active-ignores-virtual-outputs

Conversation

@HritwikSinghal

Copy link
Copy Markdown

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 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, reporting disabled: false, 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.

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 guarded recover() on omarchy-hw-external-monitors and was immune.

Fixing the helper rather than each caller corrects recover(), off(), clamshell's enable_internal()/disable_internal() and the watcher's poll in one place.

monitors all stays, so a mirrored external -- absent from plain monitors, and a real display with a connected connector -- keeps counting. That case is pinned in the new test.

OMARCHY_DRM_PATH is honoured for the same reason omarchy-hw-external-monitors honours it: the tests point it at a fixture tree.

Tests

New test/shell.d/monitor-external-active-test.sh, 9 assertions. It stubs hyprctl and builds a fixture DRM tree, following hw-external-monitors-test.sh and monitor-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 unanswered hyprctl, and an internal-only session.

Against the current helper it fails at its first assertion:

$ bash test/shell.d/monitor-external-active-test.sh
not ok - the FALLBACK output is not counted as an external monitor

With the fix, all 9 pass. The existing grep assertions on this helper in monitor-recovery-test.sh still 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 pristine quattro checkout -- see #7125.

Verifying by hand, without unplugging anything

$ hyprctl output create headless
$ omarchy-hw-external-monitors; echo "DRM check  -> $?"          # 1, correct
$ omarchy-hyprland-monitor-external-active; echo "helper -> $?"  # 0 before, 1 after
$ hyprctl output remove HEADLESS-1

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.
Copilot AI balanced review requested due to automatic review settings August 24, 2026 10:24

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.

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.

@HritwikSinghal

Copy link
Copy Markdown
Author

closed in favor of #7036

@joelclark

Copy link
Copy Markdown

Please reopen. Closing this in favor of #7036 was a mix-up — they are different bugs.

#7036 is the Display panel (hyprctl keyword is a no-op under the Lua parser) plus an explicit disabled = false on on/recover. It does not touch omarchy-hyprland-monitor-external-active.

This PR is the one that stops Hyprland's virtual FALLBACK / HEADLESS-* outputs from counting as a still-connected external, which is what makes recover() no-op after you disable the laptop panel and unplug.

Confirmed again on 2026-09-14, Omarchy 4.0.3-1, Hyprland 0.56.2: Super+Ctrl+Delete, unplug an Apple Studio Display over Thunderbolt, black screen, toggle flag never cleared. Hyprland allocated the 1920x1080 placeholder; omarchy-shell logged There are no outputs. quattro's helper is still the name-only jq. Full write-up on #8027.

@HritwikSinghal

Copy link
Copy Markdown
Author

tracked here now #12616

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Laptop display never re-enabled after unplugging an external monitor: Hyprland's FALLBACK output is counted as an external display

3 participants