Skip to content

Monitor scaling: honour desc: and multi-line hl.monitor rules for the internal panel - #8808

Open
iceteps wants to merge 1 commit into
omacom:quattrofrom
iceteps:monitor-scaling-honour-desc-and-multiline-rules
Open

iceteps wants to merge 1 commit into
omacom:quattrofrom
iceteps:monitor-scaling-honour-desc-and-multiline-rules

Conversation

@iceteps

@iceteps iceteps commented Aug 28, 2026

Copy link
Copy Markdown

What's wrong?

omarchy-hyprland-monitor-clamshell reads the internal panel's intended scale and position out of monitors.lua, but monitor_rule_regex only matches a rule that is written on one line and keyed by connector name. Two shapes that Hyprland itself honours match nothing:

The panel then falls through to the catch-all. Because the watcher re-applies the internal output every ~2s while docked, the user's arranged position is replaced with auto (#7326), and on clamshell exit enable_internal_output re-enables the panel at the remembered-or-default scale instead of the configured one.

Reproduction

Parser output for the same panel, eDP-2, description EDO EF10QBC64.C, against main (06e32d2):

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

On real hardware with a desc:-keyed multi-line rule, configured_monitor_scale returns empty and the panel is driven from the fallback instead of the config.

What this changes

  1. monitor_rules folds each hl.monitor({ ... }) call onto a single line before matching, so a multi-line rule parses identically to the single-line form. Comment stripping still happens first, so a commented-out rule still cannot pose as a real one.
  2. internal_rule_key looks the panel up by connector name first, then by any desc: rule whose text is a prefix of the panel's description — which is how Hyprland matches desc: itself.
  3. regex_escape guards the description before it goes into a pattern. Descriptions are EDID free text and routinely contain ., (, +.

A panel that no rule names still falls through to the catch-all exactly as before, so the shipped default config behaves identically.

Tests

Six cases against the patched parser, including two negative controls:

case before after
single line, connector name 1.6 / 0x0 1.6 / 0x0
desc: keyed auto / auto 1.6 / 0x0
multi-line table auto / auto 1.6 / 0x0
desc: prefix + multi-line auto / auto 1.6 / 0x0
no rule names the panel 1.25 (catch-all) 1.25 unchanged
rule commented out 1.25 1.25 unchanged

Verified on Omarchy 4.0.0-1 / Hyprland 0.56.2, Lenovo Legion 5 15IRX10, internal eDP-2 2560x1600 (203 PPI) + external HDMI-A-1 1920x1080 (102 PPI).

Fixes #7084

omarchy-hyprland-monitor-clamshell reads the internal panel's intended
scale and position out of monitors.lua, but only sees a rule written on a
single line and keyed by connector name. A rule keyed by desc: -- standard
Hyprland syntax, and the usual way to survive connectors renumbering -- and
a rule written across several lines -- what nwg-displays writes -- both
match nothing, so the panel silently falls back to the catch-all.

The watcher then re-applies the panel every couple of seconds with the
catch-all's values, discarding the position the user arranged, and on
clamshell exit re-enables it at the remembered-or-default scale rather than
the configured one.

Fold each hl.monitor({ ... }) call onto one line before matching, and look
the panel up by connector name first and then by any desc: rule whose text
prefixes its description, which is how Hyprland matches desc: itself.
Descriptions are EDID free text, so they are escaped before going into a
pattern. A panel that no rule names still falls through to the catch-all
exactly as before.

Fixes omacom#7084
Copilot AI balanced review requested due to automatic review settings August 28, 2026 19:35

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.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 75774989 by Claude Opus 5.5 in Claude Code. The second opinion could not run today because the reviewer's daily review budget is used up. So this review is one model's reading, and nothing from this branch was run.

The bug is real and still on quattro. bin/omarchy-hyprland-monitor-clamshell is unchanged on quattro since 06e32d24. Its monitor_rule_regex only matches a single-line rule keyed by connector name, so a multi-line rule or one keyed by desc: falls through to the catch-all, as this pull request describes. The branch merges cleanly into current quattro.

A competing fix is open: #7146. It fixes the same bug in the same file a different way. This pull request teaches the monitors.lua parser two more shapes: it folds multi-line hl.monitor({ ... }) calls, and it matches desc: by prefix. #7146 removes the parser instead. The command only places or removes the disabled = true overlay and reloads, so Hyprland applies the user's own rule for the panel, whatever shape it is written in. That fixes the cause rather than widening the subset of Lua the command can read. #7146 has been reproduced on a real Hyprland 0.56.2 worker with a multi-line rule and a desc: rule, and it already carries ready. So this pull request was not run on a worker this time, since two fixes for one bug cannot both land.

Codex compared the two at these same heads on 2026-09-28, while reviewing #7146, without being given an answer. It chose #7146. It also ran this branch's parser against other valid configs, and every one was still misread:

  • a Lua variable used as output
  • a single-quoted connector name
  • scale = 5 / 4
  • a rule loaded with dofile
  • a multi-line --[[ ]] comment holding a rule, where the commented-out scale was read

That comparison came from another item's review, and its independence from this session is not guaranteed.

One thing in this pull request as it stands: the six cases in the description's Tests table are not in the diff. If the maintainer prefers this approach, they belong in test/shell.d/monitor-clamshell-scale-test.sh.

Choosing between #7146 and this one is the maintainer's call. This is waiting on them.

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.

Clamshell watcher ignores desc: rules for the internal panel and overwrites its scale every 2s

3 participants