fix(monitor): fix display mirroring recovery and UI state (#6457)

* fix(monitor): prevent mirror toggle deletion during recovery and fix UI state

* Assert the external monitor helper counts mirrors as active

The helper now asks `hyprctl monitors all -j`, so the test that pinned it
to plain `monitors` failed. A mirrored external is absent from plain
`monitors`, which reads as a disconnect and hands the mirror toggle to
recovery.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Keep the mirror state line when nothing is mirrored

Piping the first mirroring monitor into the branch fed jq's test() a null
whenever no output mirrored, and jq aborts there rather than falling back
to "". The panel reads this output by line, so the missing line shifted
the focused monitor, the scale, and the display list up one, and left
mirroring reading as on whenever the external display had focus.

Select first and branch inside the pipeline, so the branch only ever sees
a monitor and the empty case falls to "" as the lines around it do.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* Cover the monitor panel state the shell reads by line

Nothing exercised omarchy-monitor-state, so both the mirror direction it
reported and the jq that reported it went unguarded. The panel reads the
output by line index, where a helper dying mid-script costs a line and
shifts every field below it into the wrong property without failing.

Assert the line count alongside the fields, over extended, mirrored both
directions, and clamshelled displays.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dimas Setia Pambudi
2026-08-11 18:25:44 +02:00
committed by GitHub
co-authored by Claude Opus 5 David Heinemeier Hansson
parent 41818ecb59
commit f4b832eba5
4 changed files with 128 additions and 4 deletions
+1 -1
View File
@@ -3,4 +3,4 @@
# omarchy:summary=Returns true when Hyprland has an active external monitor
# omarchy:hidden=true
hyprctl monitors -j | jq -e '.[] | select(.name | test("^(eDP|LVDS|DSI)-") | not) | select(.disabled == false)' >/dev/null 2>&1
hyprctl monitors all -j | jq -e '.[] | select(.name | test("^(eDP|LVDS|DSI)-") | not) | select(.disabled == false)' >/dev/null 2>&1
+1 -1
View File
@@ -13,7 +13,7 @@ printf '%s\n' "$monitors_json" | jq -r '
([.[] | select(.name | internal)][0].name // ""),
([.[] | select((.name | internal) | not)][0].name // ""),
([.[] | select((.name | internal) and .disabled != true)][0].name // ""),
([.[] | select((.name | internal) and .mirrorOf != "none")][0].mirrorOf // "")
([.[] | select(.mirrorOf != "none") | if (.name | internal) then .mirrorOf else .name end][0] // "")
'
printf '%s\n' "$focused_monitor"