Skip to content

Resize monitors without overlap, and migrate older monitors.lua files - #17166

Merged
dhh merged 4 commits into
quattrofrom
monitor-resize-no-overlap
Oct 31, 2026
Merged

dhh merged 4 commits into
quattrofrom
monitor-resize-no-overlap

Conversation

@dhh

@dhh dhh commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Two follow-ups to #17159.

No overlap warning when a monitor resizes
Changing a monitor's scale or resolution applied the new size first and moved its neighbours after, so a monitor that grew sat over its neighbour for a moment and Hyprland showed its "monitor layout is set up incorrectly" warning. Seen switching a Pro Display from 5K to 6K above a laptop.

  • omarchy-hyprland-monitor-layout --resized takes the new mode and applies it in the same eval as the neighbour moves, ordered so no step overlaps: neighbours moving away first (farthest first), then the monitor, then neighbours closing in (nearest first).
  • Saving no longer replays a monitor's settings, which could apply the new size on its own; omarchy-hyprland-monitor-persist only brings GDK_SCALE up to date, through a new update_gdk_scale().

Migrate older monitors.lua files
Older hypr/monitors.lua files still carry Omarchy's old defaults (omarchy_monitor_scale, omarchy_gdk_scale, the catch-all rule) and the comments explaining them. A migration runs the new hidden omarchy-hyprland-monitor-config-upgrade, which puts the new template on top and keeps the old file below it, minus only lines Omarchy itself shipped there:

  • the old templates' comments and examples, matched exactly;
  • the default pairs (omarchy_monitor_scale = "auto" with its catch-all rule, omarchy_gdk_scale = 2 with its GDK_SCALE line), only when unchanged and nothing else uses them.

Everything else stays exactly as written and in order, since it's the user's own Lua: connector rules, changed defaults, rotation, VRR, block comments, conditionals. Saved panel choices still win over a rule for the same monitor. The old file is kept as monitors.lua.bak.<time>, and a file that already opens like the new template is left alone.

An earlier version interpreted the file line by line and moved connector rules into saved settings; Codex and Greptile found it could activate block-commented rules, lift conditional ones and break locals, so it was replaced before shipping.

Tested with grow, shrink and three-in-a-row resize orderings, the upgrade's cases (old defaults, block comments and conditionals kept verbatim and still loadable, changed defaults and ones still in use, an already-new file), and a dry run against a real older monitors.lua.

🤖 Generated with Claude Code

dhh and others added 2 commits October 31, 2026 18:21
A scale or resolution change applied the new size first and moved the
neighbours after, so a monitor that grew sat over its neighbour for a
moment and Hyprland warned about overlapping monitors. The layout
command now takes the new mode and applies it in the same eval as the
moves, ordered so no step overlaps: the neighbours moving away first,
then the monitor, then the ones closing in.

Saving no longer replays a monitor's settings either, which could apply
the new size on its own; it only brings GDK_SCALE up to date.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An older hypr/monitors.lua still carries Omarchy's monitor defaults and
the display panel's scale as connector rules. A migration now runs
omarchy-hyprland-monitor-config-upgrade, which turns it into the new
template plus whatever else it held: the old defaults go, or become
plain lines where they were changed; a one-line connector rule with
only a mode, position and scale becomes the saved settings of the
monitor behind it, when that monitor is known; every other line is
kept below the template. The old file is kept as monitors.lua.bak.<time>.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a remaining non-blocking overlap-warning case from the previous review.

Findings

  1. P2 Moving neighbours can still overlap ▶

Summary

Updates monitor resizing and replaces the older config rewrite with a more conservative upgrade.

  • Monitor size changes apply alongside moves that make room.
  • Older monitor configs gain the new template while keeping user rules.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Change resolution or scale] --> B[Save chosen setting]
  B --> C[Update GDK_SCALE without moving monitors]
  C --> D{Other monitors connected?}
  D -->|Yes| E[Calculate positions and order moves]
  E --> F[Apply moves and resized mode in one eval]
  F --> G[Save monitor positions]
  D -->|No| H[Apply mode and scale directly]
Loading

Reviews (2) · Last reviewed commit: "Order a resize's moves along a row so no..." · Reviewed by Greptile

Comment thread bin/omarchy-hyprland-monitor-layout Outdated
| unpile
| (map(.x = .ox | .y = .oy)) as $old
| if piled and ($old | piled | not) then $old else . end
| sort_by(if .name == $name then 1 elif .x > .ox or .y > .oy then 0 else 2 end)

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.

P2 Moving neighbours can still overlap

All monitors moving away receive the same sort key, so their moves are not ordered by which destination is free. With three adjacent screens, growing the left screen can move the middle screen into the right screen's old space before the right screen moves away. The overlap warning can therefore remain for longer rows. Order moves by which destinations are free, and add a three-screen chain case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f2034a5: neighbours moving away go farthest first and ones closing in go nearest first, so none moves into a spot another hasn't left. Added three-screen row cases for growing and shrinking.

dhh and others added 2 commits October 31, 2026 18:35
The upgrade read monitors.lua line by line as if it understood Lua, so
a block comment's contents became live config, a rule inside a
conditional was lifted into saved settings, and a custom scale built
from an earlier local lost it. It now keeps the old file exactly as
written below the new template and drops only lines Omarchy itself
shipped there: its old comments and examples, and its defaults where
they're unchanged and nothing else uses them. A file that already opens
like the template is left alone. Its tests join monitor-scaling-test.sh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every neighbour moving away shared one place in the eval, so in a row
of three the middle screen could move into the far one's spot before it
had left. Neighbours moving away now go farthest first, and ones
closing in nearest first.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants