Repository navigation
Monitor: report Hyprland scale and persist named outputs - #12263
chessing234 wants to merge 9 commits into
Conversation
4002d36 to
95ba8da
Compare
Automated AI review
Verified: the new two-way scale search follows Hyprland's search order, 89-step bound and give-up case, and persisting to the focused output's own
1. The appended fallback rule overrides
|
| Mode, request | Panel label / sent value | Hyprland result | Compared with base |
|---|---|---|---|
| 2944x1840, preset 3 | 3.07 / 3.06667 | re-snaps to 3.2 with an "Invalid scale" notification; a raw 3 gives 2.875 | same on base |
| 1600x900, CLI 2.25 | sends 2.08333 | re-snaps to 2.0 | base sent 2.5, which Hyprland also picks for a raw 2.25 |
| 1648x927 (custom mode), request 2 | 1.72 / 1.71667 | re-snaps to 1; a raw 2 gives 2.575 | new with the two-way search |
Impact: on these modes the panel label and the applied scale disagree, and some CLI requests land further from the request than on base. Across 84 realistic panel modes checked with the presets, only 2944x1840 and 3000x1875 disagree, and both disagreed on base too.
Suggested change: keep the new search, but test each candidate the way Hyprland does: w / (k / 120) and h / (k / 120) must be whole in double arithmetic, in all three places. In an isolated sweep, that one change matched a transcription of Hyprland's scale search for every on-grid request tested (presets and 0.05 steps). Optional test improvement: the hyprlandScale oracle in monitor-test.sh uses the same integer test as the code, so its sweep cannot detect this. Switching it to the double-division test makes the sweep catch these cases.
4. Inserting a missing scale after a trailing comma produces invalid Lua
For a multi-line named rule without scale, replace_scale appends , scale = X right after the last non-space character before }:
hl.monitor({
output = "eDP-1",
mode = "preferred",, scale = 1.6
})Impact: luac rejects the file (unexpected symbol near ','), so on the next reload Hyprland loads no rules or GDK_SCALE from monitors.lua. The script still reports success. The shape is uncommon, since nwg-displays always writes scale, but a trailing comma is valid in hand-written Lua tables.
Suggested change: skip the separator when the previous character is already , or {, or insert scale = X, on its own line after the output line.
5. Comments are edited as if they were live rules
replace_scale only skips lines that start with --. Lines inside a --[[ ... ]] block and trailing -- ... scale = N comments are treated as config. For example, a commented-out hl.monitor({ output = "eDP-1", ... }) inside a block comment is rewritten while no active rule changes.
Impact: the script reports success, so the generic and append fallbacks are skipped and the new scale is not persisted at all. With a block comment on base, the catch-all variable was updated correctly.
Suggested change: strip line and block comments before matching in replace_scale, as has_named_output already does for line comments.
6. The clamshell poller still reverts multi-line internal rules
omarchy-hyprland-monitor-clamshell only parses one-line hl.monitor rules. With the default local omarchy_monitor_scale = 2 and a multi-line eDP-1 rule, this PR writes 1.6 into the rule, but the poller reads 2 from the variable and applies it again while an external monitor is connected.
Impact: in that configuration the new scale is reverted within about two seconds while docked. Base wrote the variable instead, so the poller agreed with it.
Suggested change: teach the poller's rule parser the multi-line form that the scaling script now writes.
Review information
Test scope: source review of the PR against Hyprland v0.56.2 (the scale search is identical in v0.53.3 to v0.55.4) and nwg-displays v0.4.4. The real scaling and clamshell scripts ran in isolated sandboxes with a stubbed hyprctl against about 25 monitors.lua shapes at head and base. Resulting files were checked with luac and with a Lua model of Hyprland's rule lookup. The changed repository tests pass at head; the JavaScript test ran under Deno rather than Node or Quickshell. No live compositor was used, so Hyprland outcomes come from source transcriptions, and layout effects after a reload were not tested.
AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments with targeted follow-up questions, Opus 5.5 Medium editorial check.
Opt out: To stop receiving these reviews, reply to this comment saying so.
mv replaced a stow-managed monitors.lua link; cat through the link keeps the target. Also avoid a double comma when inserting a missing scale.
|
addressed the review: named-rule updates write through symlinks now, and inserting a missing scale no longer doubles a trailing comma. |
95ba8da to
3cab508
Compare
Automated AI review
Follow-up to the earlier review and the author's reply, checked at Verified: both fixes in the reply work. The new write-through has one new gap when the write fails (below).
Resolved2. Symlinks: absolute, relative and chained links to single-line and nwg-displays multi-line files all stay links, the target receives the new scale, other rules are unchanged, and no temp files are left behind. The new test fails against the previous script and passes at this head, so it guards the regression. It covers only the single-line shape. 4. Trailing comma: a multi-line or single-line rule ending in Still presentFindings 1, 3, 5 and 6 reproduce at this head as originally described, including every number in the finding 3 table; the code behind them is identical to the earlier head (for finding 5, the new commit changed only the separator, not the comment handling). For finding 5, one more shape: when the last field line of a rule without New: a failed write-through still reports success
cat "$tmp" >"$file"
rm -f "$tmp"
return 0The status of
Impact: uncommon triggers (full disk, I/O error, read-only files or directories), but the partial-write case leaves a Suggested change: check the write, keep the staged copy on failure and return a code the caller treats as fatal, for example: if ! cat "$tmp" >"$file"; then
echo "Could not write $file; update kept in $tmp" >&2
return 2
fi
rm -f "$tmp"Then have Related PR: open #13142 changes the live Review informationTest scope: source review of the new commit and rebase against Hyprland v0.56.2 (scale search unchanged on current main) and nwg-displays v0.4.4. The real scaling and clamshell scripts ran in isolated sandboxes with a stubbed AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
[Medium impact] The changes since the previous review appear safe to merge. SummaryUpdates monitor scale choices to search nearby values and skip presets the display cannot reach.
No new actionable issues were found since the previous review. The earlier comment-related findings no longer apply because scaling saves settings separately instead of rewriting Lua monitor rules. Reviews (5) · Last reviewed commit: "Keep compositor-backed scale regression ..." · Reviewed by Greptile |
|
Reviewed at 5c10dfa. The classification is unsettled, so this PR has no class label yet and nothing was run on a worker. Two models classified it separately and disagreed. Opus 5.5 read it as a Open #13142 rewrites the same persistence block in Next step: the maintainer decides whether this is a fix or a feature. Once that is settled it will be verified on a worker against |
Integer divisibility accepts scales that Hyprland skips after double division. On 1600x900 a request for 2.25 was rewritten to 2.08333, reapplied as 2, and labelled 2.08, while the compositor chooses 2.5 for the original request. Use the compositor's whole-pixel check in the CLI, stepping and panel model, and cover the mismatch in the existing tests. Co-Authored-By: GPT-6 High <[email protected]> Co-Authored-By: Opus 5.5 High <[email protected]>
The mode sweep repeats the bounded search and acceptance test used by cleanScale, so shared mistakes pass both copies. Keep the focused regressions checked against the running compositor instead of maintaining another implementation as its own oracle. Co-Authored-By: GPT-6 High <[email protected]> Co-Authored-By: Opus 5.5 (default effort) <[email protected]>
|
Verified the scale-search fix on an Omarchy ISO worker running Hyprland 0.57.2. At 1856×1392, requesting 1.25 applied 1.3333334 on base and 1.2083334 on this branch, matching a direct Hyprland request; restoring base brought the failure back. Pushed GPT-6 High in Codex reviewed this with Opus 5.5 High and muse-wonder via pi, thinking high. Their final code review found no blocking defects and agreed with the result; independence is not guaranteed. Opus 5.5 at default effort also assessed the test scope. This is waiting on the author to update the title and body to describe the current scale-search change and add the captures below to a Screenshots section. The body still describes the removed Lua persistence rewrite, and the visual-evidence CI check requires screenshots in the body. The captures show the scale row at the same 1856×1392 mode and scale 1; the 1.25 preset's label changes from 1.33x to 1.21x. The live command checks above establish which scale was applied. |


Consolidates the monitor scaling and persistence work from #8066 and #8145. The branch updates named output rules, retains symlinked dotfiles and displays effective preset scales.
The review follow-up stages monitor and GDK edits together and atomically replaces the resolved configuration target only after every transformation succeeds. Missing rules remain distinct from processing failures. A failed parse, partial staged write, GDK edit or final rename leaves the original bytes intact and returns an error explaining that the live change was not saved. Publication preserves file mode, ownership and extended attributes, requires write access to the target directory and replaces the target inode.
Validation: 26 scaling groups and 29 monitor-model groups pass on macOS. Four injected failures preserve the original content and symlink, return failure and clean temporary files. The previous source fails the processing-error regression. The macOS GNU cp lacks xattr support, so a private adapter exercised that copy step; native Linux attribute preservation and the running desktop were not tested.
This does not resolve all review findings. Description-based/custom catchall rules, Lua block/trailing comments and separators, appended-rule layout defaults, the clamshell multiline parser, and exact compositor scale acceptance still need work and native validation. The scale model tests demonstrate current branch behavior, not independent agreement with a running Hyprland compositor.