Skip to content

Leave an auto-scaled internal panel alone in clamshell recovery - #7581

Merged
dhh merged 1 commit into
omacom:quattrofrom
fuchsblau:clamshell-respect-auto-scale
Aug 22, 2026
Merged

dhh merged 1 commit into
omacom:quattrofrom
fuchsblau:clamshell-respect-auto-scale

Conversation

@fuchsblau

@fuchsblau fuchsblau commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Symptom

With the stock monitors.lua (omarchy_monitor_scale = "auto"), the internal panel's scale flaps: every idle-wake it jumps to 2, every config reload it returns to whatever Hyprland's auto actually resolves (1.5666667 on my 2256x1504 @ 198 DPI panel, 1.5 on the reporter's 143 DPI panel in #7265). #7301 is the same loop seen from the screensaver side: dismissing the screensaver runs omarchy-system-wake, which snaps the scale back to 2.

Root cause

omarchy-hyprland-monitor-clamshell runs from omarchy-system-wake after every idle cycle. Its sync_internal_scale reads the configured scale, and for "auto":

  1. valid_scale accepts only numbers, so auto is rejected,
  2. the $SCALE_STATE fallback usually doesn't exist (it is only written when clamshell disables the panel),
  3. read_monitor_scale lands on the hardcoded fallback echo 2,
  4. sync_internal_scale sees 2 != auto's resolution and force-applies 2.

Deterministic repro on a live system with scale = "auto":

$ hyprctl monitors -j | jq '.[0].scale'    # 1.5666667 (auto, after any reload)
$ omarchy-hyprland-monitor-clamshell
$ hyprctl monitors -j | jq '.[0].scale'    # 2
$ hyprctl reload && sleep 1
$ hyprctl monitors -j | jq '.[0].scale'    # 1.5666667 again

For what it's worth, the EDID-timing guess in #7265 doesn't reproduce: DPMS off/on cycles and a full monitor eDP-1, disable → re-enable cycle all keep auto's value stable. Only this script flips it.

Fix

A config without a usable number — the default "auto", or an expression only Hyprland's Lua can evaluate (scale = 3 / 2) — delegates the scale to the compositor: whatever it resolved for the enabled panel is the configured scale, so sync_internal_scale now leaves it alone instead of substituting a number. The guard tests valid_scale on the configured value rather than special-casing the "auto" string, so expression scales stop flapping too, and the configured scale is read once per sync instead of twice (read_monitor_scale accepts the already-read value).

Recovery of a disabled panel is unchanged: it still re-enables with the remembered scale (falling back to the historical default 2), and clamshell disable still records the active scale first — so the remembered value under auto is auto's own resolution, not the fallback.

This deliberately flips one existing assertion: the previous test required auto's resolution to be "corrected" to 2 (clamshell recovery ignores transient auto scale). That assumption — that auto's resolution is transient noise and 2 is the real value — is precisely what #7265/#7301 report as a bug, so the test now asserts the panel is left alone.

Tests

monitor-clamshell-scale-test.sh grows from 20 to 25 cases:

  • enabled panel left alone under: the bare auto local, the shipped default's catch-all-rule shape, an explicit scale = "auto" on the internal rule, and an expression scale (each fails against the unpatched script),
  • numeric configs keep both sync behaviors: matching active scale not reapplied, drifted active scale corrected back,
  • disabled-panel recovery under auto with no remembered state still applies the echo 2 fallback.

All 25 pass; ./test/all shows no new failures against the baseline on my machine.

Known bounded residual: if hyprctl monitors is transiently unreadable right after the lid-open reload, sync can still pin a number over auto until the next reload; the pre-existing code had the same window with a worse outcome, so it is left out of scope here.

Live verification: with the patch, running the script under scale = "auto" no longer changes the active scale; idle-wake cycles keep 1.5666667.

Fixes #7265. Fixes the scale-revert half of #7301 (the "sub-1080p should default to 1x" suggestion there is a separate question).

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings August 20, 2026 07:12

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.

Pull request overview

Prevents clamshell recovery from overriding Hyprland’s resolved scale when the internal panel uses "auto".

Changes:

  • Leaves enabled auto-scaled panels unchanged.
  • Adds regression coverage for global and explicit "auto" scales.

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 Skips numeric scale synchronization for enabled auto-scaled panels.
test/shell.d/monitor-clamshell-scale-test.sh Updates and expands auto-scale regression tests.

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

With the default scale = "auto", sync_internal_scale read the config,
rejected "auto" as non-numeric, fell back to the hardcoded default 2,
and force-applied it whenever the compositor's auto resolution differed.
Since the script runs from omarchy-system-wake after every idle cycle,
the panel flapped between 2 and auto's own value (1.5666667 on a 198 DPI
panel) on every wake/reload pair.

A config without a usable number -- "auto", or an expression only
Hyprland's Lua can evaluate -- delegates the scale to the compositor:
whatever it resolved for the enabled panel is the configured scale, so
there is nothing to correct. Recovery of a disabled panel is unchanged
and still re-enables it with the remembered scale, falling back to the
historical default 2.

Fixes omacom#7265. Also the scale-revert half of omacom#7301.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L4Z6GimYhR1Kpsir24VAPF
Copilot AI review requested due to automatic review settings August 20, 2026 07:46
@fuchsblau
fuchsblau force-pushed the clamshell-respect-auto-scale branch from ab6efdd to b14c7d7 Compare August 20, 2026 07:46

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.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

@omarchybot

Copy link
Copy Markdown
Collaborator

Verified against the source and on hardware-equivalent VMs. This is the right fix, and it is the one #6909 needs.

What the guard actually changes. sync_internal_scale runs on every pass of the 2-second poll omarchy-hyprland-monitor-watch starts whenever a laptop has an external monitor attached (sync_poll_state, bin/omarchy-hyprland-monitor-watch:77-87), and again from omarchy-system-wake after every idle cycle. With the shipped monitors.lua the scale it re-asserted was the hardcoded 2 at bin/omarchy-hyprland-monitor-clamshell:137, reached because omarchy_monitor_scale = "auto" fails valid_scale and no $SCALE_STATE exists until clamshell has disabled the panel once. Reading the configured scale before deciding, rather than after substituting a number for it, is what removes the guess — the panel keeps whatever Hyprland resolved, and there is no longer a number for the poll to drag it back to.

Recovery paths are intact. I walked every caller of sync_internal_scale and enable_internal_output and every state the panel can be in. A panel that is off — clamshell-disabled, manually disabled, absent, or reporting a null scale — leaves current_internal_scale empty, fails valid_scale, bypasses the guard, and still recovers from the remembered scale and then the historical 2. enable_internal still reloads and still re-enables DPMS. The new optional argument to read_monitor_scale does not disturb its zero-argument call from enable_internal_output, and (( $# )) is correct under set -u and with an empty argument.

The new tests earn their place. Reverting bin/omarchy-hyprland-monitor-clamshell to its parent (9455496) while keeping the new test file, four assertions fail and only those four:

not ok - clamshell recovery leaves an auto-scaled panel alone
not ok - clamshell recovery leaves the shipped auto default alone
not ok - clamshell recovery leaves an expression-scaled panel alone
not ok - clamshell recovery leaves an explicitly auto panel alone

The second of those is the shipped config's exact shape, which is the one that matters for the reports. The negative ! grep -F 'scale = ' assertions are not vacuous: the harness runs under set -euo pipefail, so a script that exited non-zero would abort the file rather than pass it, and the positive assertions interleaved through the same file would fail if the stub hyprctl were never reached. Restoring the patch, all 25 pass, and ./test/all is green — all 184 test files — on a clean Omarchy VM.

On the residual you named. A hyprctl monitors that is unreadable in the window right after the lid-open reload can still pin a number over auto, and that pin now lasts until the next reload instead of being re-asserted every two seconds. That is not a regression: the old code pinned the same number in the same window and then kept pinning it, so the outcome is strictly better in both the common and the unlucky case. Agreed it belongs outside this PR.

Scope, against the other open work. This covers configs where the internal panel has no numeric scale to find — the shipped default and anything else resolving to auto or to an expression. It does not cover a rule the parser cannot read in the first place: desc:-keyed rules and rules spread over several lines still fall through to the same fallback, which is #7146's half. #7505 is a third thing again — omarchy-hyprland-monitor-scaling's sed writing one monitor's scale to the global — and nothing here touches it. Between them the three cover what #6909 collects; none of them is a duplicate of another.

Reviewed independently by codex at xhigh, which found no defects. Where it agrees with the above it is agreement rather than a second discovery: its sandbox restricts writes but not reads, so its independence is not guaranteed. It could not run the test file; that ran on the VM instead.

Nothing to change here. Waiting on a maintainer.

@dhh
dhh merged commit b636164 into omacom:quattro Aug 22, 2026
sgruendel pushed a commit to sgruendel/omarchy that referenced this pull request Aug 22, 2026
…om#7581)

With the default scale = "auto", sync_internal_scale read the config,
rejected "auto" as non-numeric, fell back to the hardcoded default 2,
and force-applied it whenever the compositor's auto resolution differed.
Since the script runs from omarchy-system-wake after every idle cycle,
the panel flapped between 2 and auto's own value (1.5666667 on a 198 DPI
panel) on every wake/reload pair.

A config without a usable number -- "auto", or an expression only
Hyprland's Lua can evaluate -- delegates the scale to the compositor:
whatever it resolved for the enabled panel is the configured scale, so
there is nothing to correct. Recovery of a disabled panel is unchanged
and still re-enables it with the remembered scale, falling back to the
historical default 2.

Fixes omacom#7265. Also the scale-revert half of omacom#7301.


Claude-Session: https://claude.ai/code/session_01L4Z6GimYhR1Kpsir24VAPF

Co-authored-by: Claude Fable 5 <[email protected]>
@fuchsblau
fuchsblau deleted the clamshell-respect-auto-scale branch August 23, 2026 08:44
dhh pushed a commit that referenced this pull request Aug 23, 2026
With the default scale = "auto", sync_internal_scale read the config,
rejected "auto" as non-numeric, fell back to the hardcoded default 2,
and force-applied it whenever the compositor's auto resolution differed.
Since the script runs from omarchy-system-wake after every idle cycle,
the panel flapped between 2 and auto's own value (1.5666667 on a 198 DPI
panel) on every wake/reload pair.

A config without a usable number -- "auto", or an expression only
Hyprland's Lua can evaluate -- delegates the scale to the compositor:
whatever it resolved for the enabled panel is the configured scale, so
there is nothing to correct. Recovery of a disabled panel is unchanged
and still re-enables it with the remembered scale, falling back to the
historical default 2.

Fixes #7265. Also the scale-revert half of #7301.

Claude-Session: https://claude.ai/code/session_01L4Z6GimYhR1Kpsir24VAPF

Co-authored-by: Claude Fable 5 <[email protected]>
(cherry picked from commit b636164)
@dhh dhh mentioned this pull request Aug 23, 2026
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
…om#7581)

With the default scale = "auto", sync_internal_scale read the config,
rejected "auto" as non-numeric, fell back to the hardcoded default 2,
and force-applied it whenever the compositor's auto resolution differed.
Since the script runs from omarchy-system-wake after every idle cycle,
the panel flapped between 2 and auto's own value (1.5666667 on a 198 DPI
panel) on every wake/reload pair.

A config without a usable number -- "auto", or an expression only
Hyprland's Lua can evaluate -- delegates the scale to the compositor:
whatever it resolved for the enabled panel is the configured scale, so
there is nothing to correct. Recovery of a disabled panel is unchanged
and still re-enables it with the remembered scale, falling back to the
historical default 2.

Fixes omacom#7265. Also the scale-revert half of omacom#7301.


Claude-Session: https://claude.ai/code/session_01L4Z6GimYhR1Kpsir24VAPF

Co-authored-by: Claude Fable 5 <[email protected]>
@emirb emirb added this to the 4.5 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scale = "auto" is not stable across evaluations: 2 at boot, 1.5 after hyprctl reload

5 participants