Skip to content

Refactor monitor_rules for better rule processing - #7408

Closed
yi-zelin wants to merge 1 commit into
omacom:quattrofrom
yi-zelin:yi-zelin-patch-1
Closed

yi-zelin wants to merge 1 commit into
omacom:quattrofrom
yi-zelin:yi-zelin-patch-1

Conversation

@yi-zelin

Copy link
Copy Markdown

Fixes #7326

What's wrong?

nwg-displays generate multi-line formatted Lua monitor configs (where hl.monitor({, output, and scale sit on separate lines).

Because omarchy-hyprland-monitor-clamshell pipes monitors.lua line-by-line into sed, configured_monitor_value() fails to match the regular expression, which expects the entire hl.monitor({ ... }) declaration to reside on a single line. This parsing failure causes read_monitor_scale() to fall back to the default scale = 2, continuously reverting fractional scale configurations.

What does this PR do?

  • Updates monitor_rules() to flatten multi-line table declarations into a single stream using tr '\n' ' '.
  • Injects a newline before each hl.monitor declaration using sed 's/hl\.monitor/\n&/g'.
  • Ensures each monitor definition is isolated onto its own line so the existing downstream regex parser can reliably extract keys without modifying the underlying extraction logic.

fix(monitor-watch): support multi-line lua monitor configs generated by GUI tools
Copilot AI balanced review requested due to automatic review settings August 18, 2026 17:56

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

Thanks for tracking this down, @yi-zelin. The bug is real: on quattro, monitor_rules hands the key parser one physical line at a time, so an hl.monitor({ ... }) rule split across lines the way nwg-displays writes it never matches, and the panel falls back to the catch-all scale and position = "auto" (#8123, #8335).

This pull request is one of two open fixes for that same bug, and I'm recommending the other one, #8808, to the maintainer rather than this one. What I checked, reading only (nothing was run, since a fix that won't be taken forward isn't worth a worker): this diff against quattro's bin/omarchy-hyprland-monitor-clamshell and the shipped config/hypr/monitors.lua, and both competitors, #8808 and #7146.

Why #8808 over this one:

#8808 isn't flawless either; its own review will cover what it needs. #7146 removes the parser entirely as part of a much larger rework of clamshell recovery, so it resolves this only as a side effect.

The second opinion came from Codex Medium, asked to pick among the three without being told my answer. It also chose #8808, and it found the statement-leak case above, which I then checked against the source. It can read this session's working files, so its agreement isn't guaranteed to be independent.

This now waits on the maintainer to decide between the competing fixes. Nothing was pushed to your branch.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this, @yi-zelin. #8808 fixes the same problem in a way the review judged better, so this is closed in favour of it. If it does not cover your case, please say so there.

Closed at the maintainer's request. The review comment above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent.

@omarchybot omarchybot closed this Oct 1, 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.

Internal monitor position cannot be made to stick: clamshell watcher and Display panel scaling both re-apply position = "auto"

3 participants