Skip to content

Recover the laptop panel when the external monitor disappears - #11654

Closed
BigTorro wants to merge 2 commits into
omacom:quattrofrom
BigTorro:fix/fallback-output-monitor-recovery
Closed

BigTorro wants to merge 2 commits into
omacom:quattrofrom
BigTorro:fix/fallback-output-monitor-recovery

Conversation

@BigTorro

Copy link
Copy Markdown

The problem

Disable the laptop panel (SUPER + CTRL + Delete, or clamshell), then lose the external monitor — unplug the cable, or let a resume drop it — and the machine is left with no screen at all. Pressing the shortcut again usually does not bring it back; a reboot does.

Why

When the last enabled monitor goes away, Hyprland brings up a headless output named FALLBACK (CFallbackStateKeeper, src/state/FallbackState.cpp; present in 0.56.2). It reports disabled: false under a name no internal-panel pattern matches, which is exactly the shape omarchy-hyprland-monitor-external-active looks for:

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

So the helper answers "yes, an external display is active" about the very output whose disappearance created it. Every recovery path reads that answer, and they all stand down:

omarchy-hyprland-monitor-internal recover() external-active && return 0 — never clears the flag
omarchy-hyprland-monitor-clamshell enable_internal() [[ -f $MANUAL_DISABLE_FLAG ]] && external-active && return 0
omarchy-hyprland-monitor-watch sync_poll_state keeps polling as if still docked, reconciling nothing
off()'s "Can't disable the only active display" guard passes, so the shortcut can disable the only real panel

Reproduced in a nested Hyprland — disable the internal output, remove the external one:

{"name":"WAYLAND-1","disabled":true}
{"name":"FALLBACK","disabled":false,"width":1920,"height":1080}
external-active → true

It also happens in the wild. On my machine xdg-desktop-portal-hyprland enumerated FALLBACK twice in one session, and one of them is the resume path rather than an unplug:

18:52:09  idle lock
18:56:08  Lid closed → Suspending...
20:54:55  resume
20:54     disable_internal runs   (mtime of toggles/hypr/internal-monitor-scale)
20:55     FALLBACK created        → black screen until reboot

The panel itself is fine: dropping the disable rule and reloading recovers it every time. Nothing was dropping the rule.

The fix

1. Ask a DRM connector, not a name. New omarchy-hyprland-monitor-physical lists the enabled monitors backed by a real connector under /sys/class/drm, and external-active is now defined in terms of it. A fallback output — or one from hyprctl output create — cannot stand in for a display. Every caller is fixed by that one change, the off() guard included.

An unreadable or empty DRM tree reports nothing rather than everything. Failing that way re-enables a panel that did not need it; failing the other way leaves the machine with no screen.

2. Keep asking. The reconciliation poll only ran while an external monitor was active, so it stopped at the moment the panel needed re-enabling, leaving the three fixed retries in sync_clamshell_after_monitor_change as the last word — and a resume can consume all three while Hyprland is still reconfiguring. It now also runs while a flag holds the panel off, and still stops on its own once the flags clear. recover() sends a notification when it re-enables a panel by itself, past both guards so it fires on the transition and not on every poll.

Trade-off worth flagging

Anyone driving a headless output with no physical display attached can no longer disable the internal panel while that output is the only one, and the recovery would re-enable it. That follows from treating a DRM connector as the definition of a display; making an exception for user-created headless outputs would put the two safeguards in conflict.

Testing

  • ./test/cli green; ./test/shell has the same 6 pre-existing failures as quattro does on this machine (omarchy-pkgs checkout absent, and locate-test.sh chokes on the __pycache__ the suite itself writes into bin/), none in the changed area.
  • New test/shell.d/monitor-physical-test.sh covers the fallback output, user-created headless outputs, mirrors, monitors disabled on purpose, and an unreadable DRM tree.
  • test/shell.d/monitor-recovery-test.sh now exercises the poll condition functionally instead of asserting the old helper's jq text.
  • Counter-checked both safeguards one at a time: restoring the old external-active turns the new test red, and dropping the flag arm of the poll condition turns the recovery test red.
  • First commit verified green on its own in a separate worktree.

🤖 Generated with Claude Code

https://claude.ai/code/session_0152hkn3EdSGLSwnWBF22xeZ

Losing the last enabled monitor makes Hyprland bring up a headless output
named FALLBACK. It reports disabled:false under a name no internal-panel
pattern matches, so omarchy-hyprland-monitor-external-active answered yes
to the very display whose disappearance created it.

That answer is what every recovery path reads, so unplugging an external
monitor while the laptop panel was disabled -- by SUPER + CTRL + Delete or
by clamshell -- left the machine with no screen and nothing willing to
re-enable one: recover() in monitor-internal returned early, enable_internal()
in the clamshell sync returned early, and the "Can't disable the only active
display" guard stopped protecting anything.

Ask a DRM connector instead. omarchy-hyprland-monitor-physical lists the
enabled monitors that have one, so neither the fallback nor a `hyprctl output
create` headless can stand in for a display. An unreadable DRM tree reports
nothing rather than everything: re-enabling a panel that did not need it
costs a flicker, the opposite costs the only screen.
The reconciliation poll only ran while an external monitor was active, so it
stopped at the very moment the panel needed re-enabling, leaving the three
fixed retries in sync_clamshell_after_monitor_change as the last word. A
resume can consume all three while Hyprland is still reconfiguring its
monitors, and then nothing asks again.

Run the poll while a flag still holds the panel off as well as while docked.
Both flags clear once the panel is back, so it still stops on its own.

Recovery also reports itself now: a panel the user switched off coming back
by itself is the one state change nothing else accounts for. The notification
sits past both guards, so it fires on the transition and not on every poll.
@csfh

csfh commented Sep 13, 2026

Copy link
Copy Markdown
Member

We definitely have to solve this problem as it's described, but I do have concerns about the drawbacks.

I'm wondering if there isn't another way to recover the laptop panel in hyprland. Maybe headless is a more controlled setting so the signal is stronger whether or not to start the laptop panel back up again after loss of externals.

@BigTorro

Copy link
Copy Markdown
Author

Agreed. Keying on the fallback output is the narrower signal, and it leaves outputs created with hyprctl output create behaving exactly as today. Hyprland identifies that output by the same name, so matching it is as reliable as its own check.

#10586 already does exactly that for #10584 / #10935 and predates this PR, so I'm closing this in favour of it and adding my data points there.

@BigTorro BigTorro closed this Sep 13, 2026
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.

2 participants