Skip to content

Fix Display panel display toggle using rejected hyprctl keyword - #13725

Merged
dhh merged 2 commits into
omacom:quattrofrom
houz42:fix/monitor-panel-display-toggle
Oct 4, 2026
Merged

dhh merged 2 commits into
omacom:quattrofrom
houz42:fix/monitor-panel-display-toggle

Conversation

@houz42

@houz42 houz42 commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Problem

The Display panel's per-display enable/disable toggle (the monitors row) silently does nothing on current Omarchy.

Panel.qml builds the toggle command with the hyprlang-era CLI:

actionProc.command = ["hyprctl", "keyword", "monitor", name + (enabled ? ",disable" : ",preferred,auto,auto")]

Under the Lua config system, hyprctl keyword is rejected:

$ hyprctl keyword monitor eDP-1,disable
keyword can't work with non-legacy parsers. Use eval.

Worse, hyprctl keyword exits 0 despite the rejection, so the panel's Process reports success and the UI gives no feedback. Reproduced on Omarchy 4.0.4 (Hyprland with Lua config): clicking the checkbox for any display never changes its state.

Fix

Drive the monitor through the hl.monitor eval API instead — the same mechanism omarchy-hyprland-monitor-scaling already uses:

var expr = enabled
  ? 'hl.monitor({ output = "' + name + '", disabled = true })'
  : 'hl.monitor({ output = "' + name + '", disabled = false, mode = "preferred", position = "auto", scale = "auto" })'
actionProc.command = ["hyprctl", "eval", expr]

Two details worth noting:

  • disabled = false must be explicit on re-enable: hl.monitor rules merge, so without it a disabled = true already in config (e.g. the internal-monitor-disable toggle file from omarchy hyprland monitor internal off) survives and the re-enable silently no-ops.
  • Connector name comes from hyprctl monitors JSON and matches ^[A-Za-z0-9._-]+$, so interpolating it into the eval string is safe.

Verification

Verified live on Omarchy 4.0.4 with the stock panel cloned to a user plugin (omarchy plugin clone omarchy.monitor) and this patch applied:

  • Disable: hyprctl eval 'hl.monitor({ output = "eDP-1", disabled = true })' → eDP-1 drops out of hyprctl monitors (previously: no-op).
  • Re-enable: the disabled = false variant brings eDP-1 back at preferred/auto/auto (the plain variant without disabled = false does not — see above).
  • Shell hot-reloads the patched plugin (Local plugin changed, reloading) with no QML errors; panel still summons and refreshes state from omarchy monitor state.

Semantics are unchanged from the original intent: runtime-only toggle (no persistence), same guard against disabling the last enabled display.

Tests

./test/all: config-test, snapper-test, and unowned-system-paths-test fail identically on a clean quattro checkout (pre-existing); sleep-lock-test flips pass/fail across runs on both branches (flaky). None are related to this change.

Under the Lua config system, 'hyprctl keyword monitor ...' is rejected
("keyword can't work with non-legacy parsers") yet still exits 0, so the
panel's enable/disable row silently did nothing. Use the hl.monitor eval
API instead, as omarchy-hyprland-monitor-scaling already does.

The re-enable must pass disabled = false explicitly: hl.monitor rules
merge, so a disabled = true already in config (e.g. the
internal-monitor-disable toggle file) otherwise survives and the
re-enable no-ops.
@jandrusk

Copy link
Copy Markdown

Switching to hyprctl eval / hl.monitor is the right fix for Lua-config Hyprland (keyword is rejected).

Blocking (defense in depth): the connector name is still interpolated into a Lua string with no runtime check:

var expr = enabled
  ? 'hl.monitor({ output = "' + name + '", disabled = true })'
  : 'hl.monitor({ output = "' + name + '", disabled = false, mode = "preferred", position = "auto", scale = "auto" })'
actionProc.command = ["hyprctl", "eval", expr]

The comment says names match ^[A-Za-z0-9._-]+$, but nothing enforces that before eval. A quote or metachar in name breaks out of the Lua string. Please reject/escape before building expr:

if (!/^[A-Za-z0-9._-]+$/.test(name)) return
var expr = enabled
  ? 'hl.monitor({ output = "' + name + '", disabled = true })'
  : 'hl.monitor({ output = "' + name + '", disabled = false, mode = "preferred", position = "auto", scale = "auto" })'
actionProc.command = ["hyprctl", "eval", expr]

Hyprland lets a headless output take any name (`hyprctl output create headless <name>`), so a name with a quote broke out of the Lua string and the toggle failed for that output. Escape backslashes and quotes instead of asserting a character set the names do not actually follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Codex Medium <[email protected]>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 3, 2026
@greptile-apps

greptile-apps Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Changes how the display panel toggles monitor state.

The PR should not merge until re-enabling a display preserves its configured scale.

Findings

  1. P1 Re-enable resets display scale ▶
  2. P2 Toggle lacks regression coverage ▶

Summary

The PR replaces the Display panel’s rejected hyprctl keyword toggle with hyprctl eval calls to hl.monitor.

  • It explicitly clears disabled when re-enabling a display.
  • Re-enabling currently overrides a saved numeric display scale with auto.

Reviews (1) · Last reviewed commit: "Escape the output name in the Display pa..."

var output = '"' + name.replace(/[\\"]/g, "\\$&") + '"'
var expr = enabled
? 'hl.monitor({ output = ' + output + ', disabled = true })'
: 'hl.monitor({ output = ' + output + ', disabled = false, mode = "preferred", position = "auto", scale = "auto" })'

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.

P1 Re-enable resets display scale

When a user re-enables a display after setting a numeric scale through the panel, this command applies scale = "auto" instead of the saved scale. The live display can then use a different scale from the value saved for the monitor and GDK_SCALE, until the configuration is reapplied.

Comment on lines +306 to +309
var expr = enabled
? 'hl.monitor({ output = ' + output + ', disabled = true })'
: 'hl.monitor({ output = ' + output + ', disabled = false, mode = "preferred", position = "auto", scale = "auto" })'
actionProc.command = ["hyprctl", "eval", expr]

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 Toggle lacks regression coverage

Neither branch of the panel’s new eval command has an automated test. A focused test of the generated arguments, especially disabled = false on re-enable, would help catch another silent toggle failure; the existing monitor tests cover shell-script callers, not this panel action.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@omarchybot omarchybot added the ready Good to merge label Oct 3, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed and verified, with one small fix pushed to your branch.

The bug is real. On a worker built from the Omarchy ISO (Hyprland 0.56.2, Lua config) with a second headless output, hyprctl keyword monitor HEADLESS-1,disable prints keyword can't work with non-legacy parsers. Use eval. and exits 0. Driving the Display panel itself with the keyboard (open it, move to the second display, press Return) left the output enabled at this PR's parent, 9d61915. At the head the same keystrokes disabled it, and a second Return re-enabled it at preferred/auto/auto.

Pushed: e0b0f34, escaping the output name. The comment said connector names always match ^[A-Za-z0-9._-]+$, but hyprctl output create headless <name> accepts any name. A name containing a quote broke out of the Lua string, and the toggle failed for that output. The commit escapes backslashes and double quotes before building the hl.monitor call, and drops that claim from the comment. On the worker, an output named q"out could not be disabled at 1095f73 and toggles off and on at e0b0f34. This also covers @jandrusk's point. I escaped the name rather than rejecting non-matching names, because a regex guard would leave such outputs untoggleable. The command is an argv array with no shell, so this was a correctness issue, not a security one.

Tests, on the worker at e0b0f34: ./test/cli passed, and so did test/shell.d monitor-test, monitor-scaling-test, monitor-clamshell-scale-test, monitor-recovery-test and runtime-smoke-test.

Second opinion: Codex Medium reviewed the change twice. The first round found the quoting issue above and confirmed that scale = "auto" and disabled are valid hl.monitor fields on 0.56.2. The second round, on e0b0f34, found nothing more. It agreed with the rest of the review, and because it can read this review's own notes, that agreement is not guaranteed to be independent. It also noted two behaviours this PR leaves as the old keyword path had them: re-enabling resets a display to preferred mode, auto position and auto scale rather than restoring its configured settings, and a config reload can undo a panel toggle when the internal-monitor or clamshell toggle files say otherwise. Neither is a defect in this change. Greptile flags the first as P1: a scale saved through the panel (omarchy_monitor_scale in monitors.lua) isn't reapplied when a display is re-enabled, until the config reloads. That's accurate, but the old NAME,preferred,auto,auto keyword command used auto scale too, so this PR keeps the toggle's original behaviour. Whether re-enabling should restore configured settings is a design question for the maintainer, not something to change here. Greptile's P2 asks for a test of the generated arguments. The worker run above exercises both branches through the real panel, so I haven't added one.

The change is proportionate: one function, the same hl.monitor eval mechanism the omarchy-hyprland-monitor-* scripts already use. I found no open issue describing this bug and no competing pull request.

CI (Greptile) has passed on e0b0f34. Nothing is left for you to do. This is waiting on the maintainer.

@dhh
dhh merged commit 2b2d462 into omacom:quattro Oct 4, 2026
1 check passed
oliverlukschander added a commit to oliverlukschander/omarchy-mac that referenced this pull request Oct 11, 2026
The toggle keeps upstream's escaped hl.monitor eval from omacom#13725. The
built-in panel goes through omarchy-hyprland-monitor-internal instead, so
the choice holds through reloads and clamshell, and while the display module
arranges displays an external one goes through it, so it stays off through
later rules and comes back where it was. The port's displayToggleCommand
helper goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ryanrhughes pushed a commit that referenced this pull request Oct 16, 2026
Fix Display panel display toggle using rejected hyprctl keyword

(cherry picked from commit 2b2d462)
@emirb emirb added this to the 4.0.5 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants