Skip to content

fix(shell): use hyprctl eval and internal monitor helper in display panel - #8728

Closed
agush22 wants to merge 5 commits into
omacom:quattrofrom
agush22:fix/monitor-toggle-hypr-eval
Closed

agush22 wants to merge 5 commits into
omacom:quattrofrom
agush22:fix/monitor-toggle-hypr-eval

Conversation

@agush22

@agush22 agush22 commented Aug 28, 2026 •

Copy link
Copy Markdown

Summary

  • Fix monitor toggles in Hyprland Lua mode: The Quickshell Display panel previously used hyprctl keyword monitor ..., which is rejected by Hyprland 0.56+ when running the Lua config engine and silently no-ops.
  • Explicit enable flag: Re-enabling a monitor in Hyprland Lua requires an explicit disabled = false in hl.monitor(); otherwise Hyprland preserves the disabled state.
  • Omarchy helper integration: Routed internal laptop monitor toggles through omarchy-hyprland-monitor-internal on/off so that toggle state files (~/.local/state/omarchy/toggles/hypr/), desktop notifications, and recovery logic stay in sync.
  • Safety sanitization: Added regex validation (^[A-Za-z0-9._-]+$) on connector names before embedding into hyprctl eval, showing a notification on refusal.
  • Layout integration: Conditionally calls apply_monitor_layout() (when re-enabling) to immediately reposition displays upon toggling.

Files Changed

  • shell/plugins/panels/monitor/Panel.qml — updated toggleDisplay(...) to dispatch hyprctl eval for external monitors, route laptop displays through omarchy-hyprland-monitor-internal, and sanitize connector names.
  • test/shell.d/panel-monitor-toggle-test.sh — added unit test verifying command mapping, internal vs. external dispatch, and name validation.

Root Cause

  • hyprctl keyword is rejected by Hyprland when using the Lua parser: "keyword can't work with non-legacy parsers. Use eval."
  • Re-enabling a monitor with hl.monitor() requires disabled = false explicitly; otherwise the monitor remains disabled: true.
  • Toggling the internal screen via raw hyprctl did not update Omarchy's toggle flag files, causing desync with the clamshell watcher.

Related Issues


Testing Performed

Automated Test Suite (All 93 passed)

# Focused and existing monitor tests (examples)
bash test/shell.d/monitor-test.sh		            # 28/28 passed
bash test/shell.d/monitor-output-name-test.sh       # 10/10 passed (2 new assertions)
bash test/shell.d/monitor-clamshell-scale-test.sh   # 25/25 passed
bash test/shell.d/monitor-recovery-test.sh          # 18/18 passed
bash test/shell.d/monitor-state-test.sh             # 5/5 passed
bash test/shell.d/monitor-scaling-test.sh           # 14/14 passed

# Aggregate result
# Result: 100 passed, 0 failed.

Live Manual Verification (Omarchy 4.0.1, Hyprland 0.56.2 Lua)

  1. External Monitor Toggle (Disable & Re-enable)

    • Clicked external monitor row to disable: verified the panel issued hl.monitor({ output = "DP-2", disabled = true }) and the display disabled immediately.
    • Clicked external monitor row to re-enable: verified hl.monitor({ output = "DP-2", disabled = false }) (and apply_monitor_layout() where applicable) restored the screen smoothly without silent rejection.
  2. Internal Laptop Monitor Toggle

    • Clicked internal monitor row: verified omarchy-hyprland-monitor-internal on|off ran and ~/.local/state/omarchy/toggles/hypr/internal-monitor-disable.lua was created/removed; the clamshell watcher remained in sync.
  3. Connector Name Sanitization

    • Verified connector names are filtered against the regex /^[A-Za-z0-9._-]+$/ before Lua evaluation; unsafe names trigger a notification and are refused.

@agush22
agush22 force-pushed the fix/monitor-toggle-hypr-eval branch 3 times, most recently from 4a30e6d to c14e46d Compare August 28, 2026 07:38
@agush22
agush22 marked this pull request as ready for review August 28, 2026 07:51
Copilot AI balanced review requested due to automatic review settings August 28, 2026 07:51

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

Fixes monitor toggling under Hyprland’s Lua configuration engine and synchronizes internal display state with Omarchy helpers.

Changes:

  • Uses hyprctl eval for external displays.
  • Routes internal display toggles through Omarchy.
  • Adds connector validation and toggle tests.

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 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
shell/plugins/panels/monitor/Panel.qml Updates monitor toggle dispatch and validation.
test/shell.d/panel-monitor-toggle-test.sh Adds monitor command-mapping tests.
Suppressed comments (2)

test/shell.d/panel-monitor-toggle-test.sh:24

  • These tests quote variables inside [[ ]]; the repository convention in AGENTS.md:26-27 is to leave variables unquoted and quote only string literals.
if [[ "$name" == "$internal" || ( -z "$internal" && "$name" =~ ^eDP ) ]]; then
  if [[ "$enabled" == "true" ]]; then

test/shell.d/panel-monitor-toggle-test.sh:30

  • This comparison quotes the variable inside [[ ]], contrary to AGENTS.md:26-27; only the literal should be quoted.
  if [[ "$enabled" == "true" ]]; then

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

Comment thread shell/plugins/panels/monitor/Panel.qml Resolved
@agush22
agush22 force-pushed the fix/monitor-toggle-hypr-eval branch from c14e46d to 2188b39 Compare August 28, 2026 07:56
@agush22
agush22 requested a balanced review from Copilot August 28, 2026 08:05

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 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread shell/plugins/panels/monitor/Model.js Resolved

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 4 out of 5 changed files in this pull request and generated no new comments.

@bjarneo

bjarneo commented Sep 21, 2026

Copy link
Copy Markdown
Member

Automated duplication check: this pull request looks similar to #7036, which covers the same monitor enable/disable path. I keep that one open and close this one to consolidate review.

If you feel this is the wrong decision, please open the PR again with a note on the difference.

@bjarneo bjarneo closed this Sep 21, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Update: #13725 has merged into quattro. The panel Lua-command failure is now fixed. This closed proposal also routed the internal display through its helper and changed the helper’s on() path; those changes did not land. Separate internal-display routing and recovery work remains open in #7036. Restoring saved layout remains outside the merged panel fix.

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

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

Labels

None yet

Projects

None yet

4 participants