#4702

Workspaces end up on the wrong monitor after power-off-monitors with two identical monitors (same make/model/serial)

Opendrumdidamopened 13d ago

I have two identical monitors (MSI G272QPF E2) that both report the same make/model and no serial number, so niri sees both as Microstep G272QPF E2 Unknown.

When swayidle runs niri msg action power-off-monitors, both monitors fully disconnect from DisplayPort (hotplug). On power-on-monitors they reconnect in a random order. The first one to come back gets the name Microstep G272QPF E2 Unknown, and the second one is unnamed:

10:50:15 DEBUG niri::backend::tty: disconnecting connector: "DP-3" 10:50:15 DEBUG niri::backend::tty: disconnecting connector: "DP-1" 10:50:17 DEBUG niri::backend::tty: new connector: DP-3 "Microstep G272QPF E2 Unknown" 10:50:18 DEBUG niri::backend::tty: new connector: DP-1 "Microstep G272QPF E2 Unknown" 10:50:18 WARN niri::backend::tty: new connector DP-1 duplicates make/model/serial of existing connector DP-3, unnaming

Later the same day, the order was reversed (DP-1 first, DP-3 unnamed):

19:44:57 DEBUG niri::backend::tty: new connector: DP-1 "Microstep G272QPF E2 Unknown" 19:44:57 DEBUG niri::backend::tty: new connector: DP-3 "Microstep G272QPF E2 Unknown" 19:44:57 WARN niri::backend::tty: new connector DP-3 duplicates make/model/serial of existing connector DP-1, unnaming

Workspaces seem to remember their original output by this name. So whenever the reconnect order differs from the order at startup, the workspaces don't go back to their original monitor and most or all of them end up on one monitor. It happens "sometimes", depending on which monitor wins the race.

Expected behavior

After a reconnect, workspaces should return to the monitor they were on. When two outputs have the same make/model/serial, niri could fall back to the connector name (DP-1 / DP-3) to tell them apart, as KDE does according to #734.

Setup

  • niri 26.04, Fedora 44, kernel 7.2.10
  • Two MSI G272QPF E2 on DP-1 and DP-3, both 2560x1440@165
  • Outputs configured by connector name: kdl output "DP-1" { mode "2560x1440@164.987"; position x=0 y=0; } output "DP-3" { mode "2560x1440@164.987"; position x=2560 y=0; }
  • swayidle: timeout 500 'niri msg action power-off-monitors' resume itors'

Related: #734, #942

niri msg outputs Output "Microstep G272QPF E2 Unknown" (DP-1) Current mode: 2560x1440 @ 164.987 Hz Variable refresh rate: supported, disabled Physical size: 600x340 mm Logical position: 0, 0 Logical size: 2560x1440 Scale: 1 Transform: normal Available modes: 2560x1440@59.951 (preferred) 2560x1440@180.000 2560x1440@164.987 (current) 2560x1440@143.972 2560x1440@119.998 2560x1440@85.000 1920x1080@119.965 1920x1080@120.000 1920x1080@119.880 1920x1080@60.000 1920x1080@60.000 1920x1080@60.000 1920x1080@59.940 1920x1080@59.940 1680x1050@59.954 1280x1024@75.025 1280x1024@60.020 1440x900@59.887 1280x960@60.000 1152x864@75.000 1280x720@60.000 1280x720@60.000 1280x720@59.940 1280x720@50.000 1024x768@75.029 1024x768@70.069 1024x768@60.004 800x600@75.000 800x600@72.188 800x600@60.317 800x600@56.250 720x576@50.000 720x480@60.000 720x480@59.940 640x480@75.000 640x480@72.809 640x480@66.667 640x480@60.000 640x480@59.940 640x480@59.940 720x400@70.082

Output "Unknown Unknown Unknown" (DP-3) Current mode: 2560x1440 @ 164.987 Hz Variable refresh rate: not supported Physical size: 600x340 mm Logical position: 2560, 0 Logical size: 2560x1440 Scale: 1 Transform: normal Available modes: 2560x1440@59.951 (preferred) 2560x1440@180.000 2560x1440@164.987 (current) 2560x1440@143.972 2560x1440@119.998 2560x1440@85.000 1920x1080@119.965 1920x1080@120.000 1920x1080@119.880 1920x1080@60.000 1920x1080@60.000 1920x1080@60.000 1920x1080@59.940 1920x1080@59.940 1680x1050@59.954 1280x1024@75.025 1280x1024@60.020 1440x900@59.887 1280x960@60.000 1152x864@75.000 1280x720@60.000 1280x720@60.000 1280x720@59.940 1280x720@50.000 1024x768@75.029 1024x768@70.069 1024x768@60.004 800x600@75.000 800x600@72.188 800x600@60.317 800x600@56.250 720x576@50.000 720x480@60.000 720x480@59.940 640x480@75.000 640x480@72.809 640x480@66.667 640x480@60.000 640x480@59.940 640x480@59.940 720x400@70.082

Activity

4
YaLTeR13d ago

This is an annoying problem because when a monitor name is available, we want to rely on the name, so that different connecting through a different connector still restores the workspaces to that monitor. This is not a theoretical problem either, DP-MST docks tend to always increase their connector number even if you don't physically replug the monitor.

So, workspaces remember the monitor by name (+model +serial). Even if they remembered by name + connector, with the current "unnaming" mechanic, they would see the same name on a different connector and assume the connector name changed, and put the workspaces there.

So, niri would need to get rid of this unnaming. But unnaming exists so that config output sections and "niri msg output" always target one specific output. And it would be a bigger change to let them target several...

drumdidam13d ago

Thanks for the explanation.

I would solve it for myself with a script which maps WorspaceIDs with output since the cable is always physically on the same connector. Would it make sense to make a configuration possible for my kind of setup - which is not uncommon i guess? Something like:

output "DP-1" { identify-by-connector }

YaLTeR13d ago

I actually think it's not very common to have 2 monitors with exactly matching name+model+serial but idk, I only have anecdotal evidence

Soulful-Sailer10d ago

I will just add that I have the same issue. I connect to my monitors through a dock and had the issue that connector names were not stable through replugging. So I used monitor names to assign not only workspaces, but display settings including position and orientation.

But I recently upgraded my side monitors with the same model for both, and now I can no longer use monitor names as one of them will be labeled "Unkown Unknown Unknown", which I understand is intentional to avoid crashes, but which monitor gets this label is a race condition and is not consistent.

This now means that if I ever re-plug my dock, my side monitors now have the incorrect positioning and orientation, and I can't use any script or external program to handle this automatically as they all use the names provided by the wayland compositor.