Skip to content

Add per-display HDR and rotation to the Display panel - #7340

Open
AllStars101-sudo wants to merge 8 commits into
omacom:quattrofrom
AllStars101-sudo:display-hdr-rotation
Open

AllStars101-sudo wants to merge 8 commits into
omacom:quattrofrom
AllStars101-sudo:display-hdr-rotation

Conversation

@AllStars101-sudo

@AllStars101-sudo AllStars101-sudo commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What this adds

Rotation and HDR controls in the Display panel, both scoped to a single display, plus the commands behind them.

Rotation is a row of chips (0° / 90° / 180° / 270°) below Scale. HDR is a switch on the hero's trailing edge, where the Bluetooth panel keeps its power switch, and appears only when the focused display's EDID advertises HDR, so displays that can't do it aren't offered a switch that would fail. Turning HDR on uses the mastering luminances from that display's own EDID; luminances already tuned by hand in monitors.lua are kept rather than overwritten.

Both sit in the panel's existing single column rather than behind any new navigation, and the panel still fits without scrolling: putting HDR in the hero rather than giving it a row of its own is what buys the space.

Screenshots

An HDR display (DP-1, a 4K QD-OLED). The HDR switch sits on the hero, and Brightness is driving SDR white inside the HDR volume rather than the backlight, which is what the caption underneath says.

display-panel-hdr

A non-HDR display, rotated (DP-3, a 4K panel at 90°). Same panel, same moment, different focused display: Scale and Rotation relabel to DP-3, 90° is the active rotation, Brightness reads that display's own backlight, and the HDR switch is absent because its EDID advertises no PQ transfer function.

display-panel-sdr-rotated

Brightness under HDR

Displays generally lock their own brightness to the HDR tone curve while in HDR. Critically, they still acknowledge a DDC/CI write and report the new value back, so nothing in the panel can detect that the change had no effect — the slider moves and the picture doesn't.

So while HDR is on, the Brightness slider drives sdr_max_luminance: where SDR white sits inside the HDR volume, and the knob that actually changes how bright the desktop looks. It stays a percentage of what the display can hold, so the control reads the same either way, with an "Adjusts SDR brightness" caption naming which knob it is on. The brightness keys still drive the backlight.

Its range tops out at the display's sustained full-field luminance rather than its peak: peak applies to small highlights, and mapping SDR white there makes a full white window dim as the panel's brightness limiter pulls power back.

Persistence

Anything set here has to survive a reload, which means editing the user's monitors.lua. Doing that with sed is what produced #6673 — the scale writer matches the catch-all rule, so one display's choice lands on every display.

omarchy-hyprland-monitor-rule parses the Lua instead. It identifies comments and long-bracket strings in one pass and makes every structural decision against that mask, so:

  • a commented-out hl.monitor example is never mistaken for a live rule — which matters because the stock monitors.lua ships full of them, and matching one would write into the documentation while the real display keeps its old value
  • --[[ ]] block comments and [[ ]] long strings can't throw off brace or quote tracking
  • a value ends at its separator, so a trailing vrr = 0, -- why comment isn't swallowed on the next write

On top of that it matches a rule by output name or by the desc: string the user wrote, keeping whichever identifier they chose; never matches the catch-all (output = ""); preserves CRLF endings and writes through a symlinked monitors.lua rather than replacing it with a regular file; and seeds a new rule from live geometry, because a rule that omits position does not inherit the catch-all's and would otherwise move the display to 0x0.

It's a general per-display writer, so it would also serve #6710's scale fix.

Keeping the layout valid

A quarter turn changes how much room a display occupies while every display keeps the position it had, so displays pinned to explicit positions collide. Repairing that afterwards is not enough: CMonitorLayoutController::checkOverlapsAndNotify fires the moment two displays overlap, and the notification stays up once the layout is valid again. So rotation moves the neighbours clear of the display's real post-rotation footprint before it turns, and no overlapping layout ever exists.

omarchy-hyprland-monitor-tidy does that work and is also available on its own, for a layout that ends up overlapping some other way. It resolves overlaps only, moving displays along the axis they were already arranged on. A gap is left alone — Hyprland never complains about gaps, and re-packing a valid layout would move displays the user placed on purpose. An earlier version that closed gaps dragged a whole row sideways when one tall display spanned two of them.

Mirrored displays are excluded, since they share a position by definition and would otherwise read as a 100% overlap and get un-mirrored.

Positions are persisted before the config write that triggers Hyprland's reload, so the reload cannot restore the old ones underneath the new geometry. And hyprctl reports a display's mode rather than its rotated result, so a quarter turn has to swap the axes before any of this arithmetic is right.

Scale changes are deliberately left alone. omarchy-hyprland-monitor-scaling has always resized without repositioning, so it hits the same overlap warning, and it was tempting to fix here. But Omarchy stores scale as a single global catch-all while positions are per display, and wiring the two together meant a display moved by tidy picked up a per-display rule pinning its current scale — which then outranked the catch-all and silently reverted every later scale change for that display. That is #6710's territory, and this PR stays out of it. omarchy hyprland monitor tidy cleans up after a scale change by hand.

New commands

omarchy hyprland monitor rotate [0|90|180|270] [--monitor OUTPUT]
omarchy hyprland monitor hdr [on|off|status] [--monitor OUTPUT] [--sdr-brightness NITS]
omarchy hyprland monitor tidy [check|apply] [--dry-run]
omarchy hyprland monitor capabilities [OUTPUT]     # hidden; EDID HDR capability
omarchy hyprland monitor rule ...                  # hidden; per-display Lua writer

omarchy-monitor-state also reports transform, hdr, and sdrMaxLuminance, which come free from the hyprctl payload it already reads. HDR capability is a slower EDID read, so the panel fetches it separately and only when the focused display changes — not on the 5s poll.

Relationship to the other open PRs

This is additive and aimed at the gap the others leave:

Happy to rebase on whichever lands first.

Test plan

Six suites under test/shell.d/, written against the commands' observable behaviour rather than their internals — each drives a real temporary monitors.lua and a stubbed hyprctl, so they'd still pass if the implementations were rewritten.

  • monitor-rule-test.sh — the Lua writer: desc: matching, catch-all isolation, commented-out rules left alone, --[[ ]] and [[ ]] tokenization, comment and CRLF preservation, symlink write-through, seeding, backup pruning, clean failure. Output is checked with luac where available.
  • monitor-tidy-test.sh — the layout arithmetic: overlap measurement, the quarter-turn axis swap, stacked arrangements staying stacked, the anchor not moving, gaps left alone, mirrored and disabled displays ignored, and planning for a pending change.
  • monitor-hdr-test.sh — capability gating and --force, tuned luminances preserved, luminances kept across off, SDR brightness validation, status shape.
  • monitor-rotate-test.sh — degree and alias parsing, the mirrored half preserved across a rotation, --no-flipped, --no-tidy, argument errors.
  • monitor-test.sh — the panel model: rotation mapping, SDR range and clamping, percentage round-trips, capability parsing.
  • monitor-state-test.sh — the new fields.
  • ./test/cli
  • Verified in the running shell on two displays: a 4K QD-OLED on HDR and a 4K SDR panel rotated 90°.
    • Focused on the HDR display: HDR switch present and on, Brightness at 89% driving SDR white with the "Adjusts SDR brightness" caption, Scale and Rotation labelled DP-1, 0° active. The whole panel fits without scrolling.
    • Focused on the rotated SDR display: the HDR switch is absent and the caption is gone, Brightness reads that display's own backlight, Scale and Rotation relabel to DP-3, and 90° is the active rotation.
    • Switched focus between the two displays 12 times in rapid succession: no process pile-up, nothing left running afterwards, and the panel settled on the correct state for the display that ended up focused rather than a stale one.
  • Sampled the live layout ~200 times per transition across grow, shrink and both rotations on a two-display setup: no overlapping layout in any sample, and the geometry round-tripped to where it started.

Note for reviewers

HDR brightness can't be verified from a screenshot — grim captures before tone mapping, so a 250→500 nit sweep moves the captured image mean by about one level. Evidence here is hyprctl monitors state and the EDID read, not before/after images.

Known limitations

  1. Under HDR the Brightness slider is remapped, not removed. This is a deliberate design decision rather than a lost capability. The backlight remains fully controllable — the brightness keys and omarchy brightness display drive it exactly as before, on every display, in HDR or out of it. What changes is only which knob the panel's slider is wired to. The panel cannot tell whether a given display honours a backlight change in HDR, because displays acknowledge the DDC/CI write and report the new value back either way, so the slider would silently do nothing on most hardware if left as it was. Pointing it at sdr_max_luminance means it always moves something the user can see. On the displays that do honour the backlight in HDR, that adjustment lives on the brightness keys instead of the slider.

  2. Tidying resolves overlaps; it does not arrange. It moves displays along the axis they were already on and won't rearrange a layout for you, and it assumes one row or one column. Add drag-to-arrange monitor layout in Display #7152's drag-to-arrange canvas is the right home for real arrangement, and this composes with it rather than competing.

  3. Scale changes still don't reposition. Unchanged from today's behaviour, and explained above — the fix belongs with whoever makes scale per-display. omarchy hyprland monitor tidy is the manual remedy in the meantime.

  4. cleanScale is only exact on the offered presets. Rounding an arbitrary scale to the nearest one Hyprland accepts isn't idempotent for every input in 1×–4×, though all six presets the panel offers are fixed points. Tightening it means changing normalizeScale's 2-decimal rounding, which matchingScaleIndex compares against — worth doing separately rather than inside this change.

  5. --force exists for enabling HDR on a display whose EDID doesn't advertise it — some displays lie or report nothing over certain adapters.

Anything the Display panel sets has to survive a reload, which means editing
the user's monitors.lua. Doing that with sed is what produced omacom#6673: the scale
writer matches the catch-all rule, so one display's choice lands on every
display.

This parses the Lua instead. It identifies comments and long-bracket strings in
one pass and makes every structural decision against that mask, so a
commented-out hl.monitor example is never mistaken for a live rule -- which
matters because the stock monitors.lua ships full of them. Rules are matched by
output name or by the desc: string the user wrote, the catch-all is never
touched, and formatting and comments survive a write.
hyprctl says what a display is currently doing, not what it can do, so a panel
has no way to tell whether an HDR switch would work before offering it.

A display's EDID carries an HDR Static Metadata Data Block, and one advertising
the PQ transfer function (SMPTE ST2084) means HDR. The same block carries the
mastering luminances Hyprland wants, so a single read both gates the control
and supplies sensible values for it.
Changing how much room a display occupies leaves every other display where it
was, so displays pinned to explicit positions collide -- which is what
Hyprland's "Your monitor layout is set up incorrectly" warning means.

Only overlaps are resolved. A gap is not an error, Hyprland never complains
about one, and re-packing a valid layout would move displays the user placed on
purpose. Mirrored displays are skipped, since they share a position by
definition and would otherwise read as a total overlap.

Callers pass --intended to describe the layout a change is about to produce, so
neighbours can be moved before the change lands rather than after: the warning
fires on the overlapping instant and stays up once the layout is valid again.
Turning HDR on takes the mastering luminances from the display's own EDID
rather than asking anyone to guess them, and leaves luminances already tuned by
hand in monitors.lua alone. Turning it off keeps those luminances, since they
are inert under sRGB and should still be there on the way back.

--sdr-brightness sets where SDR white sits inside the HDR volume. That is not
the backlight, and the two are complementary rather than alternatives, so the
help text says which is which.
Hyprland's transform is an integer 0-7 rather than an angle: 0-3 are the plain
rotations and 4-7 repeat them mirrored. This speaks degrees and keeps the
mirrored half behind --flipped, so rotating a mirrored display does not
silently unmirror it.

A quarter turn swaps how much room the display takes up, so neighbours are
moved clear of its real post-rotation footprint before it turns.
transform, colour management preset and SDR luminance all come free from the
hyprctl payload monitor state already reads.
Rotation is a row of chips below Scale. HDR is a switch on the hero's trailing
edge, where the Bluetooth panel keeps its power switch, and appears only when
the focused display's EDID advertises it. Both sit in the panel's existing
single column, and putting HDR in the hero rather than giving it a row is what
keeps the panel fitting without scrolling.

While HDR is on, the Brightness slider drives SDR white inside the HDR volume
instead of the backlight. Displays generally lock their own brightness to the
HDR tone curve in HDR, but still acknowledge a DDC/CI write and report the new
value back, so nothing here can detect that the slider did nothing. The
brightness keys still drive the backlight.

HDR capability is a slower EDID read than the rest of the panel's state, so it
is fetched only when the focused display changes rather than on the poll.
Also covers what Hyprland's monitor layout warning means and how to settle an
overlapping layout by hand.
Copilot AI balanced review requested due to automatic review settings August 18, 2026 02:16
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@DataArchitectPro

Copy link
Copy Markdown

+1 for this, a per-display HDR switch in the Display panel is the missing piece in 4.5.0 for me.

Right now the panel offers brightness, text size and scale, but HDR has to be configured by hand in monitors.lua. Having the switch appear only when the display's EDID advertises HDR (as this PR does) is the right behavior, since it avoids offering a toggle that would fail.

My setup, in case it helps with testing: Omarchy 4.5.0-3, Hyprland 0.56.2, AMD Radeon RX 6500 XT on Wayland. Happy to test a rebased version of this PR.

Is there anything blocking it besides the merge conflicts with main?

@DataArchitectPro

Copy link
Copy Markdown

@AllStars101-sudo, thanks for this PR, it is exactly what the Display panel is missing. It currently shows merge conflicts with main. Do you plan to rebase it, and is there anything you would like from others to move it forward (testing on other hardware, splitting it into smaller PRs for easier review, feedback on the brightness-slider-under-HDR question from the discussion)? I run Omarchy 4.5.0-3 on AMD (RX 6500 XT) and can test a rebased version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants