omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

nwg-displays' multi-line hl.monitor() blocks break internal-panel scale sync (resets to 2)

Open Ethanxu1 opened this issue 3 months ago • 2 comments

System details

Omarchy version: 4.0.0-1, Hardware: Lenovo Slim Pro 7 14APH8 (laptop), Kernel: Linux 7.1.8-arch1-3, GPU: NVIDIA GeForce RTX 3050 6GB Laptop GPU (GA107BM) + AMD Phoenix1 (integrated), nwg-displays version: 0.4.3-1Monitors: internal eDP-1 (2560x1600@90Hz), external HDMI-A-1 (3840x2160@60Hz, Sceptre Z27)

What's wrong?

What happened

On a laptop with an external monitor connected and active, setting the internal panel's scale to a fractional value (e.g. 1.25) via nwg-displays gets silently reverted to 2 within a couple of seconds — every time, no matter what scale is chosen. The external monitor's scale applies and holds fine; only the internal panel is affected.

Expected behavior

The internal panel should keep whatever scale is set in ~/.config/hypr/monitors.lua, same as the external monitor does.

Steps to reproduce

  1. On a laptop with an external monitor attached and active, open nwg-displays.
  2. Set the internal panel (e.g. eDP-1) scale to 1.25 (or any non-2 value) and save.
  3. nwg-displays writes ~/.config/hypr/monitors.lua using a multi-line hl.monitor({...}) block, e.g.:
    hl.monitor({
        output = "eDP-1",
        mode = "[email protected]",
        position = "0x0",
        scale = 1.25
    })
    
  4. Within ~2 seconds, the internal panel's scale reverts to 2.

Root cause

/usr/share/omarchy/bin/omarchy-hyprland-monitor-clamshell is responsible for re-applying the internal panel's configured scale (used to restore it correctly after suspend/resume, lid open/close, and dock/undock). Its configured_monitor_value() function locates the relevant hl.monitor({...}) block with a sed regex that requires output = "..." to appear on the same source line as hl.monitor({:

monitor_rule_regex() {
  printf '^[[:space:]]*hl\\.monitor\\(\\{.*output[[:space:]]*=[[:space:]]*"%s"' "$1"
}

nwg-displays (version 0.4.3, a commonly recommended display-configuration GUI for Hyprland/Omarchy) always writes hl.monitor({...}) blocks across multiple lines, so this regex never matches for the internal panel. configured_monitor_scale() then returns empty, read_monitor_scale() falls through past the (also empty) state-file fallback, and returns the hardcoded default of 2.

This function is called from sync_internal_scale() → enable_internal(), which runs:

  • on every monitoradded/monitorremoved Hyprland event, and
  • every 2 seconds via poll_clamshell_state in omarchy-hyprland-monitor-watch, which runs continuously whenever omarchy-hw-laptop && omarchy-hyprland-monitor-external-active (i.e. exactly the "laptop + external monitor" setup where this bug shows up).

So any scale set on the internal panel gets reapplied and stomped back to 2 within ~2 seconds. External monitors are untouched because this script only manages the internal/laptop output.

Confirmed manually

  • hyprctl eval 'hl.monitor({ output = "eDP-1", mode = "[email protected]", position = "0x0", scale = 1.25 })' applies immediately, then reverts to scale: 2 within ~2-4 seconds (caught via hyprctl monitors polling).
  • Reformatting the same block onto a single line in monitors.lua lets configured_monitor_value() parse it correctly and the scale then holds.
  • Seeding ~/.local/state/omarchy/toggles/hypr/internal-monitor-scale with 1.25 (the parser's secondary fallback, checked before the hardcoded default) also works around it without touching monitors.lua formatting — this is what I'm using as a temporary fix, but it silently goes stale the next time the scale is actually changed via nwg-displays.
  • Also noticed (separately, likely unrelated): two copies of omarchy-hyprland-monitor-watch were running simultaneously in my session, seemingly a leftover from a prior Hyprland reload — doubles the polling but isn't the cause of the scale-reset bug itself.

Suggested fix

Make configured_monitor_value()'s parsing multi-line aware — e.g. flatten each hl.monitor({...}) block onto one logical line before matching (strip newlines between the balanced { and }), or replace the regex-based scrape with a proper Lua parse — since nwg-displays, a standard/recommended tool for this workflow, never emits single-line calls.

Ethanxu1 avatar Aug 25 '26 00:08 Ethanxu1

Same root cause reproduced on Omarchy 4.0.0-1 / Hyprland 0.56.2 against main (06e32d2), and there is now a fix in #8808.

monitor_rule_regex in omarchy-hyprland-monitor-clamshell only matches a rule written on one line and keyed by connector name, so both a desc:-keyed rule and a multi-line hl.monitor({ ... }) table parse as nothing and the panel falls through to the catch-all:

monitors.lua form configured_monitor_scale read_monitor_position
single line, connector name 1.6 0x0
desc: keyed auto auto
multi-line table auto auto

#8808 folds each hl.monitor({ ... }) call onto one line before matching and looks the panel up by connector name first, then by any desc: rule whose text prefixes the panel's description (Hyprland's own desc: matching). A panel that no rule names still falls through to the catch-all, so the shipped default config is unaffected.

iceteps avatar Aug 28 '26 19:08 iceteps

Reviewed against current quattro (c352b62d) by Claude Opus 5.5 in Claude Code, with Codex Medium as the second opinion. Nothing was run on a worker for this issue. The fix below was verified on one as its own item.

The cause is still on quattro. monitor_rule_regex in bin/omarchy-hyprland-monitor-clamshell only matches a rule whose output = "..." sits on the same line as hl.monitor({, so the multi-line rule nwg-displays writes is not read as the panel's rule. Codex pointed out that the symptom has narrowed since 4.0.0-1. With the shipped catch-all (scale = omarchy_monitor_scale, which is "auto"), sync_internal_scale now leaves an enabled panel alone. The scale is still overwritten every two seconds when the catch-all carries a number, and it can still fall back to the remembered scale or 2 when the panel comes out of clamshell while still reported disabled.

A fix is open: #7146, which already says it closes this issue. It takes the reader out instead of teaching it more shapes. The clamshell command now only adds or removes a disabled = true overlay for the panel and reloads, so Hyprland applies your own rule however it is written. At its head ebd47f66, nothing in bin/ reads a scale from monitors.lua and reapplies it to the internal panel. Codex checked this independently and agreed.

Two other open pull requests fix the same parser a different way: #8808, which folds multi-line rules and matches desc:, and #14583. Which one lands is the maintainer's call, so this issue waits on them. The temporary workaround in the report, seeding internal-monitor-scale, only helps when the catch-all has no numeric scale.

omarchybot avatar Oct 09 '26 00:10 omarchybot