Disable Display Hotplug on Plasma and Wayland

Hello there,

recently I’ve bought a KVM Switch to be able to switch between my main PC and my WFH-Laptop.
My Setup includes two monitors, the second screen is directly connected to my PC, the main display is connected to the KVM, which in turn has my PC and the Laptop plugged into it.
My plan is to switch the main monitor while keeping the secondary screen always showing whatever I put on there using my PC.

However, when I switch the KVM to the Laptop, it seems that the main monitor gets “unplugged” from my PC, all applications move over to the second screen and rearrange themself. Switching back “restores” my plasma configuration with all the bars, but keeps the application windows on the second screen.

Now I’ve been looking for a way to disable this automatic display detection and “hardcode” my current display setup, so that the “unplugging” of my main monitor doesn’t cause the windows to move. Do you guys happen to know where I can configure this? I haven’t been able to find anything usable online :frowning:

The Switch I’m using is this one https://www.amazon.de/DisplayPort-Tastatur-Maus-Druckermonitor-USB-Kabel-Switch-Button-Kabel-Stromkabel/dp/B08RHSKKXJ/ref=sr_1_81?crid=2ULR34H6556LW&keywords=kvm+switch+displayport&qid=1671669208&sprefix=KVM+Switch+Display%2Caps%2C68&sr=8-81

The main display is a LG 27UP650-W connected via DisplayPort

Operating System: EndeavourOS
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.100.0
Qt Version: 5.15.7
Kernel Version: 6.0.12-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 5800X 8-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 6800 XT
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7C91
System Version: 2.0
System:
  Kernel: 6.0.12-arch1-1 arch: x86_64 bits: 64 Desktop: KDE Plasma v: 5.26.4
    Distro: EndeavourOS
Machine:
  Type: Desktop Mobo: Micro-Star model: MAG B550 TOMAHAWK (MS-7C91) v: 2.0
    serial: <superuser required> UEFI: American Megatrends LLC. v: A.90
    date: 03/17/2022
CPU:
  Info: 8-core model: AMD Ryzen 7 5800X bits: 64 type: MT MCP cache: L2: 4 MiB
  Speed (MHz): avg: 3712 min/max: 2200/4850 cores: 1: 4484 2: 3789 3: 3787
    4: 2200 5: 3798 6: 4749 7: 3798 8: 4441 9: 4354 10: 3789 11: 2200 12: 3797
    13: 3798 14: 2200 15: 3780 16: 4437
Graphics:
  Device-1: AMD Navi 21 [Radeon RX 6800/6800 XT / 6900 XT] driver: amdgpu
    v: kernel
  Device-2: MacroSilicon type: USB
    driver: hid-generic,snd-usb-audio,usbhid,uvcvideo
  Display: wayland server: X.org v: 1.21.1.4 with: Xwayland v: 22.1.5
    compositor: kwin_wayland driver: X: loaded: amdgpu
    unloaded: modesetting,radeon dri: radeonsi gpu: amdgpu resolution:
    1: 2560x1440 2: 1920x1080
  API: OpenGL v: 4.6 Mesa 22.2.3 renderer: AMD Radeon RX 6800 XT (navi21
    LLVM 14.0.6 DRM 3.48 6.0.12-arch1-1)
Audio:
  Device-1: AMD Navi 21/23 HDMI/DP Audio driver: snd_hda_intel
  Device-2: AMD Starship/Matisse HD Audio driver: snd_hda_intel
  Device-3: MacroSilicon type: USB
    driver: hid-generic,snd-usb-audio,usbhid,uvcvideo
  Device-4: Corsair VIRTUOSO SE Wireless Gaming Headset type: USB
    driver: hid-generic,snd-usb-audio,usbhid
  Sound API: ALSA v: k6.0.12-arch1-1 running: yes
  Sound Server-1: PipeWire v: 0.3.61 running: yes
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    driver: r8169
  IF: enp7s0 state: up speed: 1000 Mbps duplex: full mac: d8:bb:c1:3f:35:45
  Device-2: Realtek RTL8125 2.5GbE driver: r8169
  IF: enp42s0 state: down mac: d8:bb:c1:3f:35:44
  Device-3: Microsoft Xbox 360 Wireless Adapter type: USB driver: xpad
  IF-ID-1: docker0 state: down mac: 02:42:3f:1d:4e:51
Drives:
  Local Storage: total: 6.48 TiB used: 2.21 TiB (34.1%)
  ID-1: /dev/nvme0n1 vendor: Samsung model: SSD 970 EVO Plus 1TB
    size: 931.51 GiB
  ID-2: /dev/sda vendor: Samsung model: SSD 830 Series size: 119.24 GiB
  ID-3: /dev/sdb vendor: Western Digital model: WD30EZRX-00D8PB0
    size: 2.73 TiB
  ID-4: /dev/sdc vendor: Samsung model: SSD 860 EVO 1TB size: 931.51 GiB
  ID-5: /dev/sdd vendor: Western Digital model: WD20EZRZ-00Z5HB0
    size: 1.82 TiB
Partition:
  ID-1: / size: 287.31 GiB used: 229.4 GiB (79.8%) fs: ext4
    dev: /dev/nvme0n1p5
  ID-2: /boot/efi size: 96 MiB used: 29.1 MiB (30.3%) fs: vfat
    dev: /dev/nvme0n1p1
Swap:
  Alert: No swap data was found.
Sensors:
  System Temperatures: cpu: 68.1 C mobo: N/A gpu: amdgpu temp: 50.0 C
  Fan Speeds (RPM): fan-1: 790 fan-2: 2312 fan-3: 0 fan-4: 0 fan-5: 0
    fan-6: 693 fan-7: 0 fan-8: 0 fan-9: 0 fan-10: 0 gpu: amdgpu fan: 0
Info:
  Processes: 419 Uptime: 6h 9m Memory: 31.27 GiB used: 11.26 GiB (36.0%)
  Shell: fish inxi: 3.3.23

Thank you very much for your help!

This switch is designed to have one monitor hooked up between two devices and switch between the two to the same monitor. I don’t think this is what you want.

I tried to visualize my setup and issue:

When the KVM is switched to the red connection everything works as expected.
Display #1 shows my main “area” and Display #2 my secondary.

Switching to green, Display #1 shows the Desktop of my Laptop (as expected) but Display #2 gets set as the primary display of the PC, because it thinks Display #1 is disconnected.
Switching back to red restores the monitor configuration but keeps the application windows on Display #2.

Is there a way to disable the “monitor detection” and keep the Display #1 “virtually” connected, so that Display #2 doesn’t change?

The only solution I can find - which seems to be exactly what I’m after - is for GNOME and X11:

gsettings set org.gnome.settings-daemon.plugins.xrandr active false

Is there something similar for KDE + Wayland?

Have you tried going into settings, startup & shutdown, background services and uncheck kscreen2? Not sure whether this will work? You may need to reboot and check it.

1 Like

Unfortunately this doesn’t work :frowning:

did you eventually find a solution to this? this is precisely what I was thinking of doing.

Unfortunately no.
I settled on a workflow where I have another activity in Plasma. Before switching the KVM I switch to that other activity where some applications (mainly on the second display) are shared with my main activity.
It will still recognize the main display as “unplugged” and move all windows onto the second screen. Switching back to PC and then to the main activity all windows are restored just like they where previously.
It isn’t exactly what I wanted but using this workflow works out allright.