omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

monitor-workspaces.lua: workspaces shift up by +1 after monitor sleep/reconnect

Open SystJF opened this issue 1 day ago • 1 comments

System details

  • Hardware: Framework Desktop, AMD Ryzen AI Max+ 395 w/ Radeon 8060S (amdgpu)
  • Monitor: Single display on HDMI-A-1 (Samsung Electric Company S24R35xFZ)
  • Omarchy: 4.6.0rc2-1 (default/hypr/monitor-workspaces.lua identical to master at 2dfb187f)
  • Hyprland: 0.57.2-11 (omarchy), kernel 7.3.6-5-omarchy

What happens

After idle / monitor sleep (DPMS off causes the monitor to drop HPD and disconnect) and waking back up, all contiguous workspaces starting from workspace 1 have their numbers incremented by +1 (1 → 2, 2 → 3, 3 → 4, ...).

State file evidence (~/.local/state/omarchy/monitors/workspaces):

0	HDMI-A-1	Samsung Electric Company S24R35xFZ H4CW200887K
1		FALLBACK

Root cause

Two bugs in default/hypr/monitor-workspaces.lua combine to produce the shift:

  1. connected() (L153-L160) does not exclude Hyprland's FALLBACK monitor (unlike shell/Ui/OverlayWindow.qml:25):

    • When the sole physical monitor (HDMI-A-1, block 0) disconnects on sleep, Hyprland creates FALLBACK.
    • assign() gives FALLBACK block 1 (11–20) and persists it in ~/.local/state/omarchy/monitors/workspaces.
    • own_views() creates empty workspace 11 on FALLBACK.
    • merge() (L630-L655) sees HDMI-A-1 is gone and calls append_slot(1) for each occupied workspace on block 0. Because workspace 11 exists, 1, 2, 3, ... are renumbered to 12, 13, 14, ... with origin.id = 1, 2, 3, ....
  2. restore() (L616-L620) collides with the empty placeholder workspace Hyprland creates on the returning monitor:

    • When HDMI-A-1 reconnects, workspace 1 is free (it was renumbered to 12), so Hyprland places HDMI-A-1 on a fresh empty workspace 1.
    • restore() runs:
      if block_of_id(origin.id) == by_connector[monitor.name] and not hl.get_workspace(origin.id) then
        renumber(workspace, origin.id)
      elseif block_of_id(id) ~= by_connector[monitor.name] then
        adopt(workspace, by_connector[monitor.name])
      end
      
    • For 12 (origin.id = 1), hl.get_workspace(1) is non-nil (the empty placeholder), so restore() falls through to adopt(ws 12, 0) → slot 2.
    • For 13 (origin.id = 2), workspace 2 is now taken by old workspace 1, so adopt(ws 13, 0) → slot 3.
    • Every contiguous workspace starting at 1 cascades up by +1.

Bug 2 also affects multi-monitor setups whenever the block-0 monitor (1–10) is unplugged and replugged, even without FALLBACK.

Steps to reproduce

  1. On a single-monitor setup (block 0), open windows on workspaces 1, 2, and 3.
  2. Let the display disconnect on idle/sleep (or disable the output so Hyprland falls back to FALLBACK), then reconnect/wake it.
  3. Observe workspaces 1, 2, 3 have become 2, 3, 4.

Expected

Workspaces keep their original numbers (1, 2, 3) after monitor sleep/reconnect, and FALLBACK is never assigned a workspace block.

Suggested fix

  1. Ignore monitor.name == "FALLBACK" in connected(), so reconcile() returns early when no real monitors are attached (instead of merging workspaces into FALLBACK).
  2. In restore(), if hl.get_workspace(origin.id) exists on monitor with 0 windows, switch monitor to the returning workspace first so Hyprland destroys the empty placeholder, then renumber(workspace, origin.id).

Related: #19564 (same FALLBACK side note; open PRs #19641 / #17488 don't fix this shift), #17776 (similar empty-placeholder fix in move_to_monitor() only).

Filed by Gemini 4 Neon via Antigravity.

SystJF avatar Dec 02 '26 09:12 SystJF

Closing as a duplicate of #16328. That thread already covers the single-monitor case where Hyprland's temporary FALLBACK output gets a workspace block and an empty workspace on reconnect pushes the returning workspaces to higher numbers. #17213 addresses the fallback block, and #16349 addresses the empty-workspace collision. This can be reopened if there's a case those fixes miss.

GPT-6 High in Codex compared the reports against quattro. Opus 5.5 High agreed they describe the same bug. The independence of that agreement is unconfirmed. This was a source review.

omarchybot avatar Dec 02 '26 15:12 omarchybot