New monitor always appears to the right of main display in KDE

Hello all,

Not sure if this is the right section to ask this question but here it goes:

I have a two monitor setup that I use with Manjaro KDE. My main display is the right monitor and the secondary is on the left. If I switch the input on the secondary display, it becomes disabled in the display settings and when I switch the input back it appears but set on the right of the primary display.

I need to switch the display input because I have a qemu/kvm windows VM that I turn on and use with the secondary monitor.

The question is: is it possible to force the second monitor to always appear on the left of the primary display?

Cheers,

Lucian

What do you mean? Do you mean switching cables?

Have you tried setting them up in system settings? Run the command systemsetting5 and navigate to the section “Screen and Monitor” (or something similar. There you can position your monitors and select which one is the primary.

the monitor has a button and you can switch inputs from Displayport to DVID for example.

of course I looked in the display settings. I position the monitors and the trouble is that when I switch inputs, the secondary monitor becomes disabled. when I switch back, and it is enabled again, it appears to the right! not.where I positioned initially to the left. should I upload some pictures?

The monitor you don’t switch the input of, did you set that as your primary display?

I don’t use plasma, but is this not something you can set with xrandr?

for instance with something like

xrandr --output your1thmonitor --primary --auto --output your2thmonitor --auto --left-of your1thmonitor

I dont know if xrandr works with Plasma.

If it is not and your using X and not wayland you could always set it in a xorg config file

something like this I mean

Section "Monitor"
Identifier "your1stmonitor"
Option "Primary" "true"
EndSection

Section "Monitor"
Identifier "your2thmonitor"
Option "LeftOf" "your1stmonitor"
EndSection`

No, I perfectly understood now. It should remember the layout. I remember having a similar problem in the past, but plasma has been remembering layouts for long time now.

EDIT: Try to delete everything in ~/.local/share/kscreen/ and reboot with both monitors on. Then set it up again and test. The idea cam from here.

The “Anzeige und Monitor” page (I really need to switch to english…, I mean the page for setting up the displays) in plasma system settings has a checkbox to flag a screen as primary.
But I am not sure if that will solve the problem as I often use my desktop without the primary display.

But you should set your right monitor as primary, because that determines where the panel goes. I have no idea it that impacts where the monitors are placed though.

That’s indeed where you can set it to primary.

Did it bring anything?
I mean does one of the solutions help in any way?

If not can you provide the output of.

cat ~/.config/plasmashellrc  

and

kscreen-console json

both before and after the input switch?

Yes, the monitor that is the primary display I never switch its inputs. I will try xrandr in a script somehow to enable and rearrange the monitors when switching back inputs.

I did what you suggested. Inside that dir there are two more dirs called control and outputs and two files with weird names: 3bee671caf0cc5dd68b718393d0ac55d and 47473548d3cda02cbcf2fd25e1d3ad45.

The one file I found interesting is the second one because it contains this:

$ cat 47473548d3cda02cbcf2fd25e1d3ad45
[
    {
        "enabled": true,
        "id": "89739f2c246cbf814f4a352e7ea3fcdb",
        "metadata": {
            "fullname": "xrandr-Dell Inc.-DELL P2720DC-6J4GT03",
            "name": "DP-1.8"
        },
        "mode": {
            "refresh": 59.9505500793457,
            "size": {
                "height": 1440,
                "width": 2560
            }
        },
        "pos": {
            "x": 0,
            "y": 0
        },
        "primary": false,
        "rotation": 1,
        "scale": 1
    },
    {
        "enabled": true,
        "id": "5859b55804e2761b03fb5632d9b08416",
        "metadata": {
            "fullname": "xrandr-Dell Inc.-DELL U2412M-0FFXD3AB4KTL",
            "name": "DVI-D-0"
        },
        "mode": {
            "refresh": 59.950172424316406,
            "size": {
                "height": 1200,
                "width": 1920
            }
        },
        "pos": {
            "x": 2560,
            "y": 0
        },
        "primary": true,
        "rotation": 1,
        "scale": 1
    }
]

As I change inputs the primary monitor position is moved from "x": 2560 back to zero. What appears to happen is that when I change inputs on the secondary monitor kde will disable that monitor and this file changes to only include info about the primary monitor (the one I don’t change inputs on), switching the x position to 0. When I chang back the inputs on the secondary monitor, it appears as disabled at first in the display settings and when I enable it, it appers to the right on the primary. But that I think it is because the file above gets generated again, but leaving the x position to 0 on the main display.

I was thinking that maybe this can be corrected using a script (or hooks?) at the start of the VM (to switch inputs) and then at the end to place the released monitor at its correct position.

The right monitor is set as primary!

The script to setup the layout is very simple to write. I’m just not sure how to check if a new monitor as been added. The best way might be to write a systemd timer.

Below is the script I wrote for my work computer. It has two screens and occasionally I need to run one of them off (the left one - the right is the primary). I run it manually, but I had intentions of automating it when I wrote it.

[lcoimbra@dg-lcoimbra ~]$ cat /usr/local/bin/lc-xrandr 
#!/bin/bash
## Script to setup monitors
#
## By: Luís Coimbra
## Created: 2020-06-18
## Last Modified: 2020-06-18
#
## TODO: query and automation

# Declarations
MON1=VGA1
MON2=HDMI2
CURRENT=$(($(xrandr --listmonitors | awk 'END{print NR}') - 1))

# Setup monitors
if [[ "$CURRENT" == "1" ]]; then
        xrandr --output $MON1 --auto --primary --output $MON2 --auto --left-of $MON1
else
        xrandr --output $MON2 --off --output $MON1 --auto --primary
fi

cool! thank you for this! I will give it a try in a few days!