Skip to content

Require a mode before counting an external monitor as active - #12253

Open
Maximilian-Maag wants to merge 4 commits into
omacom:quattrofrom
Maximilian-Maag:fix/external-active-requires-mode
Open

Maximilian-Maag wants to merge 4 commits into
omacom:quattrofrom
Maximilian-Maag:fix/external-active-requires-mode

Conversation

@Maximilian-Maag

@Maximilian-Maag Maximilian-Maag commented Sep 17, 2026 •

Copy link
Copy Markdown

The bug

Two helpers in this repo disagree about the same monitor, and the disagreement costs you every screen you have.

omarchy-hyprland-monitor-modeless treats an enabled output with no mode as a black screen that needs recovering:

any(.[]; .disabled != true and (.width == 0 or .height == 0))

omarchy-hyprland-monitor-external-active treats that identical output as a live external screen:

.[] | select(.name | test("^(eDP|LVDS|DSI)-") | not) | select(.disabled == false)

For an external at disabled=false, 0x0, both return true at once. One half of the codebase is trying to rescue that monitor while the other half is citing it as proof a screen is already working.

Why that strands the panel

omarchy-hyprland-monitor-external-active gates the internal panel's recovery in both paths that could restore it:

# omarchy-hyprland-monitor-internal
recover() {
  omarchy-hyprland-monitor-external-active && return 0
  omarchy-hyprland-toggle-enabled $TOGGLE || return 0

  omarchy-hyprland-toggle $TOGGLE off
  wake
}
# omarchy-hyprland-monitor-clamshell
enable_internal() {
  ...
  [[ -f $MANUAL_DISABLE_FLAG ]] && omarchy-hyprland-monitor-external-active && return 0

So while a modeless external is counted as active, neither path re-enables the panel.

Reproducing it without any special hardware

This needs no dock. omarchy-hyprland-monitor-modeless already documents the trigger:

A monitor powered off at boot answers with a partial EDID carrying no video modes, so Hyprland brings it up at 0x0 and the screen stays black.

Dock a laptop with the lid shut, so clamshell disables the internal panel. Now switch the external monitor off at the wall, or let it drop signal through a KVM.

  • Hyprland keeps the output enabled at 0x0
  • omarchy-hyprland-monitor-external-active → true
  • omarchy-hyprland-monitor-internal recover → returns early
  • omarchy-hyprland-monitor-clamshell → returns early

Internal panel disabled, external showing nothing. Zero usable screens, and omarchy-hyprland-monitor-watch polls that path every 2s and returns early every time. The only way out is a blind reboot.

The fix

Require a mode. A monitor counts as a screen only once it reports one — the same standard omarchy-hyprland-monitor-modeless already applies.

Why here, rather than at the call sites

Every caller wants the same answer, and each is improved by the stricter one:

  • omarchy-hyprland-monitor-internal recover — the bug above; now recovers.
  • omarchy-hyprland-monitor-internal off — no longer agrees to blank the only real screen on the strength of a dead external.
  • omarchy-hyprland-monitor-clamshell — no longer disables the internal panel against a dead external, the same black screen reached via the lid switch.

Tests

test/shell.d/monitor-recovery-test.sh gains a decision table over the states the helper has to separate: a mode-reporting external, a mirror, an output left behind at 0x0, a laptop alone, and an external disabled on purpose. It fails without the one-line change.

Context

I hit this while chasing an undock black screen on a Dell WD22TB4. That machine turned out to have host firmware problems of its own — no Thunderbolt NHI, ucsi_acpi failing to probe, so DP Alt Mode only ever negotiates at power-on — and I want to be explicit that none of the argument above rests on that hardware. The claim here is the contradiction between the two helpers, which is visible in the source and covered by the test.

An external output unplugged with the dock can stay listed by Hyprland and
still flagged enabled while reporting no mode at all -- the 0x0 state
omarchy-hyprland-monitor-modeless already exists to detect.

omarchy-hyprland-monitor-external-active tested only `disabled == false`, so
it read that leftover as a live screen. The recover path in
omarchy-hyprland-monitor-internal returns early while an external looks
active, so the internal panel stayed disabled after undocking and the laptop
came back to a black screen -- recoverable only by replugging the dock into
another port.

Require a mode, so a monitor counts as a screen only once it reports one.
The other callers benefit from the same guard: clamshell no longer disables
the internal panel against a dead external, and `internal off` no longer
agrees to blank the only remaining screen.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@llstrk

llstrk commented Sep 25, 2026

Copy link
Copy Markdown

Automated AI review

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

Verified: the new filter does what it targets. An external that Hyprland lists as enabled at 0x0 no longer counts as active, which makes omarchy-hyprland-monitor-external-active the exact complement of omarchy-hyprland-monitor-modeless for enabled externals. Stubbed runs of every caller confirm the intended effects:

  • omarchy-hyprland-monitor-internal recover now clears a manual internal-monitor-disable toggle and wakes the panel when the only external is 0x0. Base returns early and the panel stays off.
  • omarchy-hyprland-monitor-internal off now refuses to blank the panel in that state.
  • The new decision table in test/shell.d/monitor-recovery-test.sh fails on base at the 0x0 row and passes on head.
hyprctl monitors all -j entry for an external Base Head
Enabled with a mode (including a mirror) active active
DPMS off (keeps its size) active active
Enabled at 0x0 active not active
Disabled not active not active
Hyprland's headless FALLBACK output, enabled at 1920x1080 active active

The last row is the subject of the second finding below.

The code comment and PR description describe a trigger the Hyprland source does not produce

In Hyprland 0.56.2 and aquamarine, an output's mode list is filled only when the output is created and is never refreshed while it stays connected. A running external that is switched off at the wall or loses KVM signal therefore does not drop to 0x0:

Running external, then switched off or loses signal:
  connector stays connected -> keeps its original modes and size -> base and head: active
  connector disconnects     -> output destroyed and removed      -> base and head: no external

External connects without a usable mode (for example a partial EDID):
  output created, enabled, 0x0 -> base: active, head: not active

The stuck state this PR fixes needs the manual internal-monitor-disable toggle plus an external that came up at 0x0, for example a boot with the external powered off but answering with a partial EDID (the case omarchy-hyprland-monitor-modeless documents). "The only way out is a blind reboot" is also stronger than the source supports: when clamshell alone disabled the panel, opening the lid already re-enables it on base, and SUPER + CTRL + Delete (omarchy-hyprland-monitor-internal toggle) clears the manual toggle without checking for an active external. That binding is not marked locked, so it may not work in every lock or input state.

Impact: the new comment in bin/omarchy-hyprland-monitor-external-active ("unplugged with the dock can stay listed and still flagged enabled") tells future readers this change covers an undock case that it does not reach.

Suggested change: describe the actual state in the comment, for example: an external created without a usable mode (such as a monitor answering with a partial EDID when it connects) stays listed and enabled at 0x0.

Pre-existing: Hyprland's FALLBACK output still counts as an active external after undocking

This is not introduced by the PR, and the new filter does not address it. When the last enabled output is removed, Hyprland 0.56.2 adds a headless output named FALLBACK with a 1920x1080 mode. It is not eDP/LVDS/DSI, it is enabled, and it has a size, so both base and head report an active external:

Panel off via the manual toggle, lid open, dock unplugged:
  last enabled output removed
  -> Hyprland adds headless "FALLBACK", enabled, 1920x1080
  -> external-active: true (base and head)
  -> monitor-internal recover returns early; clamshell enable_internal returns early
  -> internal panel stays off, and FALLBACK cannot show anything

The Hyprland behavior is established from source; the Omarchy decisions were confirmed with a stubbed monitor listing. It was not reproduced on hardware or in a live session.

Impact: this matches the undock black screen described in the new code comment more closely than a 0x0 leftover does, so that symptom can remain after this change.

Suggested change: exclude outputs that are not physical connectors (FALLBACK, HEADLESS-*) in the helper, or additionally require omarchy-hw-external-monitors to report a connected external. Either fits here or in a follow-up PR.

Narrow case: panel left on behind a closed lid when a 0x0 external later gains a mode

With the lid closed and an external listed at 0x0, head now runs enable_internal (panel on behind the lid) and omarchy-hyprland-monitor-watch stops its 2 s clamshell poll. If that same output later gains a mode without being unplugged and replugged, nothing re-runs clamshell: the configreloaded handler only runs recover_modeless, and the 1, 4 and 11 s re-syncs follow add/remove events only. Base is already in the correct state in that case.

This transition does not occur with Omarchy's shipped mode = "preferred" rules and an empty mode list. It needs a user-set explicit mode or modeline for that output (via monitors.lua, hyprctl keyword/eval, or a third-party output tool), or a mode list that was only rejected transiently. Whether a kernel driver accepts such a custom mode on a connector that offered no modes was not verified.

Impact: in that case the panel stays enabled behind the closed lid until a lid event, wake, suspend or monitor hotplug; workspaces moved to it likely stay there (inferred from source, not traced end to end).

Suggested change: have omarchy-hyprland-monitor-watch also run its clamshell sync and poll-state check on configreloaded, which covers the reload path. Keeping the poll running while omarchy-hw-external-monitors reports a connected external also covers eval/keyword and retry, which post no event.

Optional test improvement: on base, the new grep -F 'select(.width > 0 and .height > 0)' line makes the test exit silently under set -e before the decision table runs. With that line removed, base fails with not ok - an external monitor left behind without a mode is not active, which states the actual regression. The table already covers what the grep checks.


Review information

Test scope: Source review of the changed helper and all of its callers (-internal, -internal-mirror, -clamshell, -watch, -modeless), plus Hyprland v0.56.2 and aquamarine source for monitor listing, mode selection and fallback behavior. Omarchy does not pin a Hyprland version, so these conclusions are specific to 0.56.2. The test file ran in an isolated sandbox on base and head, and the helper and its callers ran against stubbed hyprctl listings. No live Hyprland session, dock, KVM or monitor hardware was used.

AI process: Opus 5.5 Medium coordination and synthesis; independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, each followed by targeted source questions; Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
With a 0x0 output no longer counted as an active external, a laptop that boots with its lid shut and its only external unpowered keeps the panel on and never starts the docked poll. When the monitor is switched on, the modeless recovery's reload gives it a mode, but no hotplug follows and configreloaded only ran recover_modeless, so the panel stayed enabled behind the closed lid. Run the clamshell sync and poll-state check on configreloaded too, as the hotplug events do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Codex Medium <[email protected]>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and reproduced: the fix works, and I pushed one commit on top for a regression it introduced in the watcher.

The bug is real. On a worker, with hyprctl stubbed to list the internal panel disabled and the only external enabled at 0x0, omarchy-hyprland-monitor-internal recover leaves the manual internal-monitor-disable toggle in place on quattro, clears it and wakes the panel on this branch, and leaves it in place again with the helper reverted. A working external still keeps the panel off on both.

Pushed: f85df19, "Reconcile clamshell after a reload, when a 0x0 external gains its mode". Once a 0x0 output stops counting as active, a laptop that boots with its lid shut and its only external switched off keeps the panel on and never starts the docked poll in omarchy-hyprland-monitor-watch. When the monitor is then switched on, recover_modeless reloads, and the reload gives the monitor a mode. No hotplug follows that, and configreloaded only ran recover_modeless, so clamshell never re-ran and the panel stayed enabled behind the closed lid. On quattro the poll ran in that state and caught it. configreloaded now runs the clamshell sync and poll-state check as the hotplug events do. Driving the watcher with a fake event stream on the worker: clamshell ran 0 times after the monitor gained its mode before the commit and 3 times after it. A new check in monitor-recovery-test.sh fails with the change reverted. Clamshell and both recover paths only reload when they change a flag, so a reload settles rather than loops.

One thing for the author, not blocking: the new comments in omarchy-hyprland-monitor-external-active and the test describe the 0x0 output as what an unplugged dock leaves behind. The state this repository has evidence for is the one omarchy-hyprland-monitor-modeless and 3b08a85 describe: a connected monitor that was unpowered when it came up, answering with a partial EDID. Nobody has shown the dock case on hardware here, so the comment would read better describing the enabled-but-modeless state without asserting how it arose.

Tests, on a worker built from the Omarchy ISO: ./test/cli passes, and test/shell.d/monitor-recovery-test.sh passes 21 of 21. Across the full shell suite, 239 of 244 files pass. ascii, branding-about-animation and omarchy-kernel-migration fail on this branch's fork point and on current quattro too, so they are not caused by this change. screenshot-sanity fails at the fork point but passes on current quattro. locate-test failed only because an earlier test left bin/__pycache__ behind, and it passes once that is removed. This repository has no CI on the pull request.

Overlap: #13749 edits the same line of omarchy-hyprland-monitor-external-active to ignore Hyprland's FALLBACK output. That is a different bug, so the two don't compete, but whichever lands second will need a rebase.

Second opinion: Codex Medium reviewed it in two rounds. In the first it independently traced the same watcher regression. Its other points were that the comments overstate the undock origin and that the new source grep makes the test exit on quattro before the behavioural table runs. In the second round it found nothing wrong with the pushed commit. Its independence from this review is not guaranteed.

This waits on the maintainer. It is labelled verified but not ready, because the full shell suite is not green on the worker, for the pre-existing failures above.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect laptop display recovery and clamshell synchronization.

The PR still needs the previously reported fix that preserves mirroring across temporary mode loss.

Findings

  1. P1 Temporary mode loss clears mirroring ▶

Summary

Requires positive width and height before an external monitor counts as active.

  • Only external monitors with a mode count as active.
  • Config reloads now resync clamshell monitor state.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Configuration reload] --> B[Sync clamshell state]
  B --> C[Update docked poll]
  C --> D[Check for outputs without a mode]
  D --> E{Mode available?}
  E -->|Yes| F[Stop recovery]
  E -->|No| G[Retry guarded reload with backoff]
  G --> A
Loading

Reviews (2) · Last reviewed commit: "Test that a config reload syncs clamshel..." · Reviewed by Greptile

# recover path in omarchy-hyprland-monitor-internal sees an active external and
# returns before re-enabling it. A monitor is only a screen once it reports a
# mode.
hyprctl monitors all -j | jq -e '.[] | select(.name | test("^(eDP|LVDS|DSI)-") | not) | select(.disabled == false) | select(.width > 0 and .height > 0)' >/dev/null 2>&1

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.

P1 Temporary mode loss clears mirroring

If a mirrored external temporarily reports 0x0 while its mode is being recovered, this check reports that no external is active. Clamshell reconciliation then runs mirror recovery, which removes the saved mirror toggle. When the external regains its mode, the mirror setting is not restored, so a temporary loss permanently switches the session out of mirror mode.

Knowledge Base Used: Hyprland configuration and display control

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

omarchybot and others added 2 commits November 1, 2026 11:43
The mode filter now sits beside omacom#13749's FALLBACK filter in omarchy-hyprland-monitor-external-active. The source greps this branch added to monitor-recovery-test.sh went with omacom#16334, so the 0x0 case is a behavioural check in quattro's stubbed-hyprctl style, and the fixtures carry a mode so the FALLBACK case still exercises its own filter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
monitor-recovery-test.sh lost the source grep for this with omacom#16334, so the watcher's configreloaded arm is now checked by driving the watcher with a fake event stream in monitor-modeless-test.sh, which fails with the arm reverted. It waits for the four startup syncs before clearing the log, so a startup retry that runs late cannot pass for the reload's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Codex Medium <[email protected]>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This had stopped merging after #13749 and #16334 landed on quattro, so I merged quattro into the branch and resolved the conflicts. It merges cleanly again at 776901e, and the fix still works there.

Pushed:

  • 90c8b39, a merge of quattro. Ignore Hyprland's FALLBACK output when checking for external monitors #13749 added a FALLBACK filter to the same jq line in omarchy-hyprland-monitor-external-active, and the merged line keeps both filters. Remove tests that only read source text #16334 removed tests that only grep source, and quattro's AGENTS.md now rules them out, so this branch's source greps are gone. That includes the decision-table cases for a mirror, a laptop on its own and an external disabled on purpose: they test behaviour quattro already has, and they pass without this change. monitor-recovery-test.sh now carries one case in quattro's stubbed-hyprctl style: an enabled external at 0x0 does not count as active. The existing fixtures now carry a mode, so the FALLBACK case still tests its own filter rather than passing on the new one.
  • 776901e, "Test that a config reload syncs clamshell". The configreloaded change in omarchy-hyprland-monitor-watch (from f85df19, explained in my earlier comment) had only a source grep behind it. A new case at the end of monitor-modeless-test.sh sends the watcher a configreloaded event and checks that it runs clamshell. It waits for the watcher's four startup syncs before it starts counting, so a late startup retry cannot pass for the reload's.

Checked, on a worker built from the Omarchy ISO: ./test/cli passes. monitor-recovery-test.sh passes 2 of 2 and monitor-modeless-test.sh passes 16 of 16, three runs in a row. Each fails one check with its change reverted, and reverting a change gives quattro's code for that file. In the full shell suite, 5 of 413 files fail: agent-account-exec, ascii, branding-about-animation, first-run and runtime-smoke. All five also fail on plain quattro (631dacd), so this change does not cause them. I also checked that the reload arm cannot loop. Clamshell's enable and disable, and omarchy-hyprland-monitor-internal recover, reload only when they change a flag, so the configreloaded they cause finds nothing to change and stops there.

Second opinion: Codex Medium and muse-wonder (pi, thinking high) reviewed the merge and the new test in two rounds. In the first round, both found the race that the startup wait now closes. In the second round, on 776901e, both found nothing wrong. Their independence from this review is not guaranteed.

For the author: the description's Tests section still lists the cases dropped above. Updating it would help whoever reads it at merge time.

Overlap: #16778 and #17115 also edit omarchy-hyprland-monitor-watch, for different bugs. Neither competes with this. With this branch, #16778's extra reload after recovery also triggers a clamshell sync, which settles for the reason above.

This is labelled verified again but not ready, because the full shell suite is not green on the worker for the reasons above. It now waits on the maintainer.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 29, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants