Repository navigation
Resolve omarchy_monitor_scale variable reference in clamshell recovery - #6688
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes clamshell recovery to resolve variable-based monitor scales correctly.
Changes:
- Falls back to
omarchy_monitor_scalewhen the captured scale is non-numeric. - Adds regression coverage for a specific output using variable indirection.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
bin/omarchy-hyprland-monitor-clamshell |
Resolves non-numeric scale references through the configured variable. |
test/shell.d/monitor-clamshell-scale-test.sh |
Tests variable-based scale recovery for a specific internal output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
test/shell.d/monitor-clamshell-scale-test.sh:177
- This sentence is grammatically incomplete; “Lua” needs a noun describing what the examples are.
# A nested table before the keys, and semicolons for separators. Both are Lua a
# user can reasonably write, and neither ends the rule.
The variable reference fix keyed on "the scale is not a number", which also swallowed an explicit scale = "auto" and let an unrelated local stand in for it. Read the config the way Hyprland writes it instead: a key's value is whatever sits between the `=` and the next separator, and a bare word resolves against a local only when one exists, so a quoted string stays a string. Comments are cut before anything is matched. An internal rule that names no scale still defers to the catch-all, as it always has here. Against the released script only two configs change: a pinned rule referencing omarchy_monitor_scale, which is the bug this fixes, and a quoted number in that local, which now applies instead of falling back. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
9cb6122 to
0bf19bc
Compare
|
Thanks for tracking this down — the diagnosis is exactly right. I've pushed a follow-up commit rather than asking for changes, since we're close to RC and I wanted the fix to land as one safe unit. The reason for the rework: keying the fallthrough on "the scale is not a number" is wider than the bug. It also catches values that are deliberately non-numeric, so two configs regress against the released script:
Row two is the case the "ignores transient auto scale" test was written to prevent, just reached through a pinned output instead of the catch-all. Row three reaches the The follow-up narrows the trigger: a bare word resolves against a Behavior against the released script is now down to two configs, both intentional: the bug you reported, and a quoted number in the local ( Your commit is untouched underneath. — 🤖 Claude, posting on behalf of @dhh |
omacom#6688) A pinned internal monitor rule that referenced the omarchy_monitor_scale local had the variable name captured as the scale, so clamshell recovery fell all the way to the hardcoded 2. Read the config the way Hyprland writes it: a key's value is whatever sits between the `=` and the next separator, and a bare word resolves against a local only when one exists, so a quoted string stays a string. Comments are cut before anything is matched, and position gets the same resolution since it had the identical bug. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Problem
When a user customizes
monitors.luawith a specific internal output (e.g.output = "eDP-1") while keeping the default template's variable indirection for scale, disconnecting an external monitor resets the internal panel scale to the default (2) instead of the configured value.Example config (matches the pattern the default template ships, just with a specific output):
On USB-C / external monitor unplug,
omarchy-hyprland-monitor-watchfiresomarchy-hyprland-monitor-clamshell, which callsconfigured_monitor_scale()to read the desired scale.Root cause
configured_internal_monitor_value scalegreps thehl.monitorline and captures whatever followsscale =. When the rule references the variable, the regex captures the literal stringomarchy_monitor_scale— non-empty but not a number.configured_monitor_scale()only falls through to thelocal omarchy_monitor_scale = ...lookup when the capture is empty ([[ -z $scale ]]), so the variable name leaks through,valid_scalerejects it downstream, andread_monitor_scale()returns the hardcoded default2.With the default template (
output = "") the regex never matches, so the fallback fires correctly — which is why this only bites users who pin the output name (a patternhyprland.mditself recommends).Fix
Fall through on any non-numeric capture, not just an empty one:
Reproduction
Test coverage
Adds a regression case to
test/shell.d/monitor-clamshell-scale-test.shcovering the specific-output + variable-reference combination. Verified it fails on the previous code and passes with the fix. Full existing suite still passes (the only failing suites on my machine are environment-dependent:config-testneeds anomarchy-pkgscheckout,runtime-smokeneeds a live test shell — both fail identically on pristinequattro).