Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Updates display toggling to use Hyprland’s Lua-compatible eval API.
Changes:
- Generates escaped
hl.monitorspecifications. - Routes display toggles through
hyprctl eval. - Adds unit coverage for generated specifications and escaping.
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 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
shell/plugins/panels/monitor/Model.js |
Builds Lua monitor specifications. |
shell/plugins/panels/monitor/Panel.qml |
Executes toggles through hyprctl eval. |
test/shell.d/monitor-test.sh |
Tests specification generation and escaping. |
💡 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 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (3)
shell/plugins/panels/monitor/Model.js:98
quoteLua()replaces\nbut leaves\rintact; if a display name contains Windows-style line endings (\r\n) or a bare\r, the resulting Lua source can become syntactically invalid (Lua treats CR as a newline in many contexts). Replace both\nand\r(or use a single pattern that handles CRLF) before emitting the quoted string.
function quoteLua(text) {
return '"' + String(text === undefined || text === null ? "" : text)
.replace(/\\/g, "\\\\")
.replace(/"/g, '\\"')
.replace(/\n/g, " ") + '"'
}
shell/plugins/panels/monitor/Model.js:111
- The
enabledparameter name is ambiguous here becauseenabled === trueproducesdisabled = true(i.e., it’s interpreted as “currently enabled, so disable it”). Renaming the parameter to something likecurrentlyEnabled(or flipping the boolean todisable) would make the call sites and the implementation easier to read and reduce the chance of misuse.
function displayToggleSpec(name, enabled) {
if (!name) return ""
if (enabled) return "hl.monitor({ output = " + quoteLua(name) + ", disabled = true })"
return "hl.monitor({ output = " + quoteLua(name) + ", disabled = false, mode = \"preferred\", position = \"auto\", scale = \"auto\" })"
}
test/shell.d/monitor-test.sh:28
- Since
quoteLua()is responsible for producing syntactically valid Lua source, it would be valuable to add a regression assertion for carriage returns / CRLF (e.g., an input containing\r\nor\r) to ensure the produced string can’t break thehyprctl evalLua snippet.
assertEqual(monitor.quoteLua('DP"1'), '"DP\\"1"', 'monitor escapes a quote in a display name')
|
The diagnosis is right and Two things came out of the review. Enabling still didn't work — pushed a fix (6c56c9a). The commit adds Disabling the built-in display can strand a laptop with no screen — not fixed, for you and the maintainers to decide.
The result is a laptop running on a headless fallback with a black panel and no in-session way back. This was unreachable before, because the toggle didn't do anything; making it work makes it reachable. The existing design already handles this — Tests: |
|
Independent confirmation on Omarchy 4.0.0-1 with Hyprland 0.56.2: I reproduced the original failure: I then tested the So +1 to this fix. In particular, keeping the explicit |
|
Re-reviewed at 6c56c9a. Nothing new has been pushed to the branch since the last pass, so this is about what a second round of testing established rather than about new code. The black-screen hazard is confirmed, and it is now the thing holding this PR up. Last time I traced it component by component and left it as a maintainer judgement call. This time I reproduced the whole chain on a live Hyprland 0.56.2, and it is worse than the trace suggested. It is also the same end state as open issue #7228, which has independent reporters. Measured, in order, with a headless output standing in for the external monitor: Two things came out of that which I had not established before. The disable survives a hotplug. A rule set by
So nothing re-enables the display:
And For a user that reads: close the lid setup, turn the laptop panel off from the Display panel while docked, walk away with the machine, and you have a black screen, a running session, an automatic recovery path that cannot fire, and a keyboard shortcut that appears to do nothing the first time you press it. Before this PR the toggle did not work at all, so none of this was reachable. Making it work makes it reachable, which is why it needs answering here rather than later.
On @okurmustafa's confirmation — thank you, that is useful and it matches what I measured, in particular that the explicit Two smaller things still open, neither of them blocking:
Checked and found nothing worth reporting: the Tests, on a disposable VM with the shell running from this branch ( A second opinion from Codex at xhigh went over the same ground and reached the same conclusion on all of it, including that the naming is a readability trap rather than a bug and that the quoting is unreachable — its independence is not currently guaranteed, so read the agreement as agreement rather than as confirmation. It did contribute the |
|
Confirmed on Omarchy 4.0.0-1 / Hyprland 0.56.2 with three displays (2× DP, 1× HDMI), AMD RX 9070. Toggling off and back on works in both directions with this patch applied to a cloned Can also confirm the # turns the output off
hyprctl eval 'hl.monitor({ output = "HDMI-A-1", disabled = true })'
# reports ok, but the monitor stays off
hyprctl eval 'hl.monitor({ output = "HDMI-A-1", mode = "preferred", position = "auto", scale = "auto" })'
# actually brings it back
hyprctl eval 'hl.monitor({ output = "HDMI-A-1", disabled = false, mode = "preferred", position = "auto", scale = "auto" })'Worth noting for anyone hitting this before the fix lands: the failure is completely silent from the UI side, since |
|
Re-reviewed at e11a597. Nothing had changed on the branch since the last pass, so this is about @finnbuhk's report, two issues filed today, and one commit I pushed. @finnbuhk's The middle line is the direct translation of the old Pushed e11a597 for the silent failure — and it corrects what I said about it last time. I had the channel wrong, and so does the obvious reading of @finnbuhk's note. hyprctl does not use stderr here. Measured: $ hyprctl eval 'hl.monitor({ output = "Virtual-1", disabled = )'
error: [string "hl.monitor({ output = "Virtual-1", disabled =..."]:1: unexpected symbol near ')'
$ echo $?
7That text is on stdout; stderr is empty. A It deliberately does not name the command in the message. The commit also carries Two issues filed today change what the stranding hazard is waiting on. #8027 reports the But #8028 landing would not rescue a display disabled from this panel. With the helper corrected and the external unplugged:
So the panel-disable hole needs its own answer either way, and the one-line #8010 (1Password float left off-screen after a monitor is disabled) is neither caused nor fixed by this PR — the float's global coordinates survive the layout change either way. Worth knowing that this PR gives it a one-click trigger from the Display panel that did not exist while the toggle was a no-op. Tests, on a disposable VM with the shell running from this branch, all re-run after e11a597: Reviewed by Claude Opus 5 in Claude Code, with a second opinion from Codex at xhigh. Codex caught the command-naming defect in my first draft of e11a597, so the commit as pushed is the corrected version and credits it. Its first run refused to review at all because I had moved HEAD underneath it, which was the right call; it was re-run pinned to the pushed commit. On the recovery trace above and on the rest of the diff it reached the same conclusion I did, and its independence is not currently guaranteed, so read that as agreement rather than as confirmation. Still waiting on the maintainers for the stranding question. Nothing needed from you unless you want the |
|
Independently confirmed this bug and fix on Omarchy 4.0.0-1 with Hyprland 0.56.2. The shipped The patched display rows worked after reloading the shell plugin. |
|
Re-reviewed at e11a597. The branch has not moved, so this is @szalikdev's report checked against Hyprland's own source, one new finding about the enable spec, and one open issue nobody here has named. @szalikdev's That same merge is worth one more look on the enable path, because it means the enable spec throws away settings it does not need to. Since the disable inherits the rule that was already there, everything the enable spec names overwrites it. Measured on Hyprland 0.56.2 against an output pinned to The last line is what this branch sends, so re-enabling a display from the panel discards a mode or position pinned in Issue #7607 asks for exactly the change this PR is waiting on, and its diagnosis does not hold. It reports that turning the internal display off from this panel "doesn't persist — the watcher re-enables it within ~2s while docked", and asks for the toggle to call Nothing else has changed: the stranding hazard is live at this head, #8028 landing would not close it, and it is still a maintainer decision between routing the internal display through Tests, on a disposable VM with the shell serving this branch ( |
|
When is this planned to be merged? |
|
@szalikdev — thank you. That is the third independent confirmation on 4.0.0-1 / Hyprland 0.56.2, after @okurmustafa and @finnbuhk, and the first on a two-DisplayPort desktop pair rather than a laptop. Your @GibreelAbdullah — there is no schedule, and this account does not merge anything, here or anywhere. It reviews, pushes fixes to the branch, and reports; what lands is the maintainers' call. This is not waiting on a review or on a defect. It is waiting on one product decision, and there are now two pull requests offering opposite answers to it — see the last two sections. Nothing in the diff changed since the last review; the head was the same commit. What follows is what changed around it, plus one defect found in this run. #6968 is fixed at this head, measured on a real compositor. On a disposable Omarchy VM running Hyprland 0.56.2 (
Two more measurements from the same session, because they settle open questions elsewhere: #8027 and #8028 were closed on 27 Aug pointing at this pull request, and this pull request does not fix them. #8028 was closed by its author "in favor of #7036" and #8027 closed as completed with "should be fixed by #7036". Neither is right: this branch touches only The stranding hazard is unchanged, and it is one field away — in The watcher does reach There is now a competing pull request: #8728, opened yesterday. It answers the routing question this one is parked on, by sending internal-display toggles through Pushed to this branch: 2bcb246, one defect, in the bot's own earlier commit rather than yours. e11a597 read the stdout collector from inside Tests, on a disposable VM with the compositor serving this branch ( Reviewed by Claude Opus 5 in Claude Code, with a second opinion from Codex at xhigh reasoning. Codex found the signal-ordering defect above, which neither the first review nor the previous run had caught, and independently traced the watcher's return path to the same line the worker measurement landed on. It also worked through whether an attacker-chosen monitor name can escape Nothing needed from you. |
2bcb246 to
1cfad3e
Compare
|
Re-reviewed the two new commits at Verified rather than assumed. One state where the switch still does nothing. With Exit 0 means What the new The same one-field defect you just fixed in Two smaller ones. Reviewed by Claude Opus 5 in Claude Code and by Codex at xhigh. Codex reached the mirror no-op separately from the measurement above and contributed the closed-lid and exit-status points; its independence is not currently guaranteed, because it can read this session's own transcript. Waiting on the maintainer and unchanged: the deliberate behaviour change you flagged, the choice against #8728, and #6710. |
|
Please do not treat this PR as closing #8027 / replacing #8028. This change is the right fix for the Display panel ( omarchy-hyprland-monitor-external-active && return 0Hyprland 0.56 creates a virtual Reproduced 2026-09-14 on Omarchy |
|
Independent confirmation of #6968, plus one data point on the enable path that differs from what is reported above. Setup: Omarchy 4.0.4-1, Hyprland 0.56.2, desktop with 2x DisplayPort (DP-1 [email protected] at 0x0, DP-2 same mode at 1920x0) using explicit hl.monitor entries in ~/.config/hypr/monitors.lua.
That last point may matter for the enable spec chosen here: mode = preferred, position = auto, scale = auto resets the position to auto, which collapses explicit side-by-side layouts like 0x0/1920x0. A reload-based enable (or preserving the current position in the eval) keeps them intact. I opened #13142 with the same observation for the scaling path, where position = auto had the same effect. |
Hyprland 0.55+ refuses `hyprctl keyword`, so the DISPLAYS toggle did nothing. Backport omacom/omarchy#7036 verbatim: external outputs go through `hyprctl eval` with hl.monitor, the laptop panel through omarchy-hyprland-monitor-internal. The row now flips at once and a state read from before the switch no longer restores it, so a second click cannot repeat the first while omarchy-monitor-state is slow. Fixes #1 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Following the merge of #13725, The Display panel Lua-command failure is fixed. This PR also routes the built-in display through its owning toggle command and repairs internal-display re-enable/recovery; those laptop-recovery changes remain unmerged. Scope checked by GPT-6 in Codex and Codex Medium against the discussion and landed change; review independence is not guaranteed. No tests were rerun for this cleanup. Omabot on behalf of DHH |
|
#16147 is merged now, and it covers the layout half of this: the Display panel re-enables an output with This branch conflicts with |
hyprctl prints a rejected monitor spec on stdout and exits 7, and the panel collected that stdout and threw both it and the exit code away, so a refused change looked exactly like an applied one. Measured on Hyprland 0.56.2: `hyprctl eval 'hl.monitor({ output = "Virtual-1", disabled = )'` prints `error: ...unexpected symbol near ')'` on stdout, nothing on stderr, and exits 7.
Reading stdout rather than adding a stderr sink is deliberate: the error never reaches stderr, so a stderr collector here would log nothing. The message names no command for a related reason: `actionProc` is shared with `setScale`, and either function reassigns `command` on a click that lands while the process is still running, so by the time the exit arrives the property may describe an action that was never run. hyprctl quotes the spec it refused, which is the part worth having.
That silence is what let this bug survive a release. `hyprctl keyword` goes further and exits 0 while refusing, so nothing downstream could tell the toggle had done nothing; `hyprctl eval` at least reports it, and now the panel does too.
Fixes omacom#6968
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Codex XHigh <[email protected]>
`Process.onExited` and `StdioCollector.onStreamFinished` have no guaranteed order, so reading the collector from inside `onExited` could report the exit code with an empty spec -- and the spec hyprctl quotes back is the half of the message worth having. The repo already states that ordering twice, at `shell/plugins/panels/wifiqr/Panel.qml` and `shell/plugins/panels/speedtest/Panel.qml`, and handles it the same way both times: hold what the first signal carries and let the second one publish the pair. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
omarchy-hyprland-monitor-internal on clears the disable flag and reports success, but the output stays dark. It is the same defect this branch fixes in the Display panel: hl.monitor edits the rule it finds rather than replacing it, so a monitor Hyprland has already disabled is only re-enabled by a spec that says disabled = false, and nothing here sent one. recover has it too, and that one matters more, because it is the path the clamshell watcher takes when the external display is unplugged. Both now go through enable_output, which repeats off()'s rule that only a plain connector name may be written into Lua. Stands alone from the rest of the branch.
Disabling the built-in panel from the Display panel wrote a runtime only rule: no toggle flag for the clamshell watcher to read, no guard against turning off the last display, and nothing surviving a reboot. Unplug the external after that and there is no display left and no flag to recover from, which is the end state reported in omacom#7228. omarchy-hyprland-monitor-internal already holds all three, so the internal output is routed through it and every other output keeps the direct call. Which output counts as internal comes from omarchy-hyprland-monitor-laptop by way of omarchy-monitor-state, so LVDS and DSI panels are covered rather than only the name that happens to be most common. Matching on an eDP prefix instead fails the LVDS assertion in monitor-test.sh.
Both passed against the script before enable_output existed, because each asserted only the absence of an eval that code never sent. The unsafe-name case of on now also requires the unsafeName notice. The no-flag case of recover now sees the wake as well as the eval, so it fails when the flag guard goes, with or without enable_output. With no flag, recover behaves the same before and after enable_output, so no assertion on it alone can tell the two apart; the lid-open path it leaves to the clamshell sync is pinned in that sync's own test.
on and recover ended in the wake, which never fails, so a spec hyprctl refused or a name enable_output rejected still exited 0, and the Display panel's refused-change log never fired for the built-in panel. Both now return enable_output's status, and the wake still runs either way.
1cfad3e to
cee977b
Compare
[Medium impact] The change is limited to display controls and built-in display recovery. The PR appears safe to merge, with non-blocking improvements to error reporting and panel test coverage. FindingsSummaryThe PR routes built-in display switches through
Acknowledgments from
|
| return 1 | ||
| fi | ||
|
|
||
| hyprctl eval "hl.monitor({ output = \"$INTERNAL\", disabled = false })" >/dev/null |
There was a problem hiding this comment.
Enable errors lose their explanation
enable_output discards the error text from hyprctl eval. When enabling the built-in display fails, the helper returns the failure code, but the panel warning cannot show why it failed. Keep successful output quiet, but forward the error text on failure so the journal contains more than an exit code.
| } | ||
| const invoke = vm.runInNewContext('(' + method[0] + ')', { | ||
| root: { enabledDisplayCount: count }, actionProc | ||
| root: { enabledDisplayCount: count }, actionProc, Model |
There was a problem hiding this comment.
Internal routing goes untested
The panel test never supplies root.internalMonitor, so every case takes the external-display path. The model tests cover the command builder, but would still pass if toggleDisplay stopped passing the internal display name. Add panel-level cases with internalMonitor set and check both on and off commands.
|
Looked at this again at What this pull request is hasn't been settled. I classified it as a bug fix, since it fixes things that don't work. Codex Medium, classifying on its own from the item alone, called it an enhancement, presumably because sending the built-in panel through Most of this diff targets code that
The part that still applies to What happens next: @sterre-g, if you want to keep this going, the useful shape is the one @paulogeyer suggested on 21 Oct, cut down further now that the panel switch is gone. That means a branch on current |
|
Reproduction attempt for the question in the last review: does Setup: Omarchy 4.0.6 (its
So on current Hyprland the reload does bring the panel back once the flag's rule is gone, and the One side observation: the panel came back at 60.01 Hz rather than 165.02 Hz, and was at 165.02 Hz again by the next check about a minute later. |
|
Closing: the reproduction above shows |
The display toggle in the Display widget sends
hyprctl keyword monitor <name>,disable. Under the Lua config parser that Omarchy 4 uses, hyprctl refuses the command:It refuses it and still exits 0, which is why the panel could never tell it had failed. The switch appears to do nothing, in either direction.
This sends the change as a Lua
hl.monitorcall throughhyprctl evalinstead, which does apply:Confirmed independently on three machines
hyprctl evalapproach in both directions through a locally patched Display panel.hyprctl keywordcall left both outputs unchanged; the Lua specs here disabled and re-enabled them.All three arrived independently at the
disabled = falsedetail, on a laptop and on a two-DisplayPort desktop pair.Why enabling needs
disabled = falsehl.monitoredits the rule it finds rather than replacing it. Naming only mode, position and scale, which is the direct translation of the old,preferred,auto,autostring, returnsokand leaves the output disabled.hlMonitorin Hyprland v0.56.2 (src/config/lua/bindings/LuaBindingsConf.cpp) is where that behaviour lives. The enable spec therefore saysdisabled = falseexplicitly.The built-in panel goes through the command that owns it
Disabling the built-in panel from this widget used to write a runtime-only rule. That leaves no toggle flag for the clamshell watcher to read, no guard against turning off the last display, and nothing that survives a reboot. Unplug the external after doing it and there is no display left and no flag to recover from, which is the end state reported in #7228.
omarchy-hyprland-monitor-internalalready holds all three, so the internal output is now routed throughomarchy-hyprland-monitor-internal on|offand every other output keeps the directhyprctl evalcall.This is a deliberate behaviour change and worth reviewing as one. Toggling the built-in panel now sends the same notification the keybinding does, and the disable survives a reboot instead of lasting until the next reload. Both follow from using the command that owns the flag, and both seem right for a switch in a settings panel, but they are a change rather than a fix and the call is yours. Disabling also goes through
hyprctl reload, which re-appliesmonitors.luaand so is subject to #7326 until that is settled.Which output counts as internal comes from
omarchy-hyprland-monitor-laptopby way ofomarchy-monitor-state, so LVDS and DSI panels are covered along with eDP, per #6752. Matching on aneDPname prefix instead fails the LVDS assertion inmonitor-test.sh.Routing there exposed a defect in the helper itself, fixed in its own commit so it can be taken separately:
omarchy-hyprland-monitor-internal onclears the disable flag and reports success while the panel stays dark. It is the same defect as the one above, in the other file. Clearing the flag takes the disable out of the config, buthl.monitoronly re-enables an output when a spec saysdisabled = false, and nothing sent one.recoverhad it too, and that one matters more, because it is the path the clamshell watcher takes when the external display is unplugged. Both now callenable_output, which repeatsoff()'s rule that only a plain connector name may be written into Lua.Related work
This closes #6968. #7607 asks for the same behaviour from the other direction and is a second face of it rather than a separate watcher bug: before this change the toggle never disabled anything, so what that reporter saw was the row returning on the panel's own refresh. Routing the internal panel through its own command is what closes #7607 properly.
#8728 is the closest alternative and reaches the same two conclusions, independently and after this branch:
hyprctl evalinstead ofkeyword, and the explicitdisabled = false. It also routes the internal display throughomarchy-hyprland-monitor-internal, which this branch now does as well. Three differences are worth a maintainer's attention rather than mine:String(name).indexOf("eDP") === 0, which misses the LVDS and DSI panels Treat LVDS panels as internal displays #6752 deliberately brought in. The repo already hasomarchy-hyprland-monitor-laptopfor this and it tests^(eDP|LVDS|DSI)-.on()but notrecover(), so the clamshell watcher's re-enable path keeps the missingdisabled = false.hyprctl eval ... || truediscards the exit status, which is the failure mode this PR exists to fix.Its name-validation approach is a fair alternative to escaping, and its Lua-injection test is a good one; an equivalent is in
monitor-output-name-test.shhere.#6710 rewrites this same area with
omarchy-hyprland-monitor-toggleand-override. If that is the direction, this PR should be dropped in its favour rather than merged alongside it.Two smaller neighbours, neither conflicting: #7326 on positions and scales being re-applied, which the enable spec touches because it overwrites mode, position and scale with automatic values, and #8010 on a 1Password float landing off-screen, which this gives a one-click trigger that did not exist while the toggle was inert.
#8027 and #8028 cover the
FALLBACKoutput makingomarchy-hyprland-monitor-external-activereturn true with nothing plugged in. This PR does not close #8027 and does not replace #8028.recover()still returns atomarchy-hyprland-monitor-external-active && return 0before it reads the flag, so where the helper reports a phantom external the clamshell watcher bails at that line whatever this PR does, and the recover test here stubs the helper to exit 1 rather than covering that case. The helper fix is still #8028, and it is still needed.Tests
The spec and the command choice are built in
Model.jsrather than inline in the QML, so both are covered bytest/shell.d/monitor-test.sh, which gains assertions for the external direct call, the internal panel routing in both directions, a non-eDP built-in panel, a machine with no built-in panel, and an empty name.test/shell.d/monitor-output-name-test.shgains four for the helper:onre-enabling the output,onrefusing an unsafe connector name,recoverre-enabling when the external is gone, andrecoverstaying a no-op with no flag set.Checked that they are load-bearing rather than decorative: dropping
enable_outputfromon()fails "internal on re-enables the output it stopped disabling", and selecting the internal panel byeDPprefix fails "monitor recognises a built-in panel that is not named eDP".2026-09-01
Rebased onto current
quattro(b71dcad) with no conflicts, and brought up to date against work that landed since this branch was opened.omarchy-hyprland-monitor-internal on|off. This closes the hazard the previous revision of this description named as an open maintainer question rather than answering. It is what Internal laptop display remains disabled after disconnecting external monitor #7228 and Display panel can't persistently turn off internal display — Omarchy watcher reverts it #7607 need, and it is the one substantive thing fix(shell): use hyprctl eval and internal monitor helper in display panel #8728 had that this did not.omarchy-hyprland-monitor-internalsoonandrecoveractually re-enable the output. Separate commit, applies on its own, and is a prerequisite for the routing above being correct.omarchy-hyprland-monitor-laptoprather than a name prefix, so LVDS and DSI panels behave the same as eDP.monitor-test.shandmonitor-output-name-test.sh, and verified two of them fail when their fix is reverted.