Problems with internal and external monitor

Hi,
I am using Fedora 39 KDE. My laptop has the following hardware:

$ inxi -F
System:
  Host: Fedora39-KDE Kernel: 6.6.4-200.fc39.x86_64 arch: x86_64 bits: 64
    Desktop: KDE Plasma v: 5.27.9 Distro: Fedora release 39 (Thirty Nine)
Machine:
  Type: Laptop System: LENOVO product: 82RG v: Legion 5 Pro 16ARH7H
    serial: <superuser required>
  Mobo: LENOVO model: LNVNB161216 v: SDK0T76461 WIN
    serial: <superuser required> UEFI: LENOVO v: JUCN51WW date: 08/29/2022
Battery:
  ID-1: BAT0 charge: 78.3 Wh (100.0%) condition: 78.3/80.0 Wh (97.8%)
CPU:
  Info: 8-core model: AMD Ryzen 7 6800H with Radeon Graphics bits: 64
    type: MT MCP cache: L2: 4 MiB
  Speed (MHz): avg: 524 min/max: 400/4785 cores: 1: 1397 2: 400 3: 400
    4: 400 5: 400 6: 400 7: 1397 8: 400 9: 400 10: 400 11: 400 12: 400 13: 400
    14: 400 15: 400 16: 400
Graphics:
  Device-1: NVIDIA GA106M [GeForce RTX 3060 Mobile / Max-Q] driver: nvidia
    v: 545.29.06
  Device-2: AMD Rembrandt [Radeon 680M] driver: amdgpu v: kernel
  Display: x11 server: X.Org v: 1.20.14 with: Xwayland v: 23.2.2 driver: X:
    loaded: amdgpu,nvidia unloaded: fbdev,modesetting,nouveau,vesa dri: radeonsi
    gpu: amdgpu,nvidia,nvidia-nvswitch resolution: 1: 2560x1440 2: 2560x1600
  API: EGL v: 1.5 drivers: kms_swrast,nvidia,radeonsi,swrast
    platforms: gbm,x11,surfaceless,device
  API: OpenGL v: 4.6.0 compat-v: 4.5 vendor: nvidia mesa v: 545.29.06
    renderer: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2
  API: Vulkan v: 1.3.268 drivers: radv,nvidia,llvmpipe surfaces: xcb,xlib
Audio:
  Device-1: NVIDIA GA106 High Definition Audio driver: snd_hda_intel
  Device-2: AMD Rembrandt Radeon High Definition Audio driver: snd_hda_intel
  Device-3: AMD ACP/ACP3X/ACP6x Audio Coprocessor driver: snd_pci_acp6x
  Device-4: AMD Family 17h/19h HD Audio driver: snd_hda_intel
  API: ALSA v: k6.6.4-200.fc39.x86_64 status: kernel-api
  Server-1: PipeWire v: 1.0.0 status: active
Network:
  Device-1: MEDIATEK MT7922 802.11ax PCI Express Wireless Network Adapter
    driver: mt7921e
  IF: wlp2s0 state: down mac: 2e:83:ab:18:e5:58
  Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    driver: r8169
  IF: eno1 state: up speed: 1000 Mbps duplex: full mac: 9c:2d:cd:b9:59:d0
  IF-ID-1: tun0 state: unknown speed: 10000 Mbps duplex: full mac: N/A
Bluetooth:
  Device-1: Foxconn / Hon Hai Bluetooth Adapter driver: btusb type: USB
  Report: btmgmt ID: hci0 state: up address: 10:B1:DF:E7:3D:EE bt-v: 5.2
Drives:
  Local Storage: total: 953.87 GiB used: 388.18 GiB (40.7%)
  ID-1: /dev/nvme0n1 vendor: Samsung model: MZVL21T0HCLR-00BL2
    size: 953.87 GiB
Partition:
  ID-1: / size: 31.2 GiB used: 20.37 GiB (65.3%) fs: ext4 dev: /dev/nvme0n1p3
  ID-2: /boot size: 1.9 GiB used: 355 MiB (18.2%) fs: ext4
    dev: /dev/nvme0n1p2
  ID-3: /boot/efi size: 598.8 MiB used: 49.4 MiB (8.2%) fs: vfat
    dev: /dev/nvme0n1p1
  ID-4: /home size: 888.03 GiB used: 367.41 GiB (41.4%) fs: ext4
    dev: /dev/nvme0n1p5
Swap:
  ID-1: swap-1 type: partition size: 16 GiB used: 0 KiB (0.0%)
    dev: /dev/nvme0n1p4
  ID-2: swap-2 type: zram size: 8 GiB used: 0 KiB (0.0%) dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 46.2 C mobo: 36.0 C
  Fan Speeds (rpm): N/A
  GPU: device: nvidia screen: :0.0 temp: 41 C device: amdgpu temp: 42.0 C
Info:
  Processes: 452 Uptime: 41m Memory: total: 16 GiB note: est.
  available: 14.81 GiB used: 4.13 GiB (27.9%) Shell: Bash inxi: 3.3.31
[User: jan] @ [Server: Fedora39-KDE] - [Directory: ~]

I am using the Nvidia driver, installed by use of this webpage: Installing Nvidia as primary GPU
My external monitor is a slightly curved 27" Philips EVNIA.
No idea if this has any relation to the problem but this is what I have.

In KDE it is possible to set the monitors as they are placed on the table.


As you can see here is the way I want it to be. But, sometimes I notice videos not running smoothly and I know something is wrong again.
The 120Hz vertical refresh rate is set back to 60Hz and also the external (left) monitor is placed slightly higher than the internal one. I then see this when opening the settings page:

I chose 120 Hz as refresh rate because both monitors can handle that frequency.

Is there something I did wrong, something I forgot to do, or how is it possible the monitors settings keep changing?
Who can help me this?

Thanks.

Have you switched between X11 and Wayland?

If I understand what you posted, I think you are using X11 not Wayland. I’m not advising you should switch to Wayland. I’m asking if you had switched from Wayland. I find these settings get trashed when I switch between X11 and Wayland.

Assuming this happens to you without a switch between X11 and Wayland, my next guess would be some glitch in the EDID communication makes X11 temporarily think the monitor has different characteristics. Aside from checking the cables, that guess doesn’t help you much with disgnosing or solving the problem.

Something that may help you is the fact that those settings are stored in a strangely named file in:
~/.local/share/kscreen/
I expect there are lots of other similarly strangely named files there. I only partially understand this myself (and have some complicated questions of my own about it that I’ve been trying to think of clear ways of asking).

Meanwhile, I suggest you make a backup of that whole directory after you get the settings correct again.

Then the next time it goes wrong, I think you’ll find two of the files in that directory have newer modified timestamps, one of which is the file that matters (I don’t know why a second file also changes). Once you have learned this, it may be simpler to put a restore of the file that matters into some sddm script than to manually restore it. The file matters most at the moment you login. At other times it tends to get written but not read. So it is likely best to restore it within a script that sddm runs before you login (or maybe when you login if the script is run early enough).

It also might help me or others understand what exactly is going wrong, if (when it goes wrong) you post a diff of the files that have become different from the backup of
~/.local/share/kscreen/

I have 2 versions of the file, a short one and one which is twice as long. This is the short version:

[
    {
        "enabled": true,
        "id": "440a6f2b0b82a7198da6233a937902ea",
        "metadata": {
            "fullname": "xrandr-Philips Consumer Electronics Company-27M1C5500V-AU02327005307",
            "name": "HDMI-1"
        },
        "mode": {
            "refresh": 119.99759674072266,
            "size": {
                "height": 1440,
                "width": 2560
            }
        },
        "overscan": 0,
        "pos": {
            "x": 0,
            "y": 0
        },
        "priority": 1,
        "rgbrange": 0,
        "rotation": 1,
        "scale": 1,
        "vrrpolicy": 2
    }
]

This looks good. Just before the end is says X 0 and Y 0, which probably means the monitor starts at Y 0 which is also what I want.

This is the longer version:

[
    {
        "enabled": true,
        "id": "440a6f2b0b82a7198da6233a937902ea",
        "metadata": {
            "fullname": "xrandr-Philips Consumer Electronics Company-27M1C5500V-AU02327005307",
            "name": "HDMI-0"
        },
        "mode": {
            "refresh": 119.99759674072266,
            "size": {
                "height": 1440,
                "width": 2560
            }
        },
        "overscan": 0,
        "pos": {
            "x": 0,
            "y": 160
        },
        "priority": 2,
        "rgbrange": 0,
        "rotation": 1,
        "scale": 1,
        "vrrpolicy": 2
    },
    {
        "enabled": true,
        "id": "ee1409ea86a35e8971bd0f2ad7e9356b",
        "metadata": {
            "fullname": "xrandr-BOE",
            "name": "eDP-1-0"
        },
        "mode": {
            "refresh": 120.02804565429688,
            "size": {
                "height": 1600,
                "width": 2560
            }
        },
        "overscan": 0,
        "pos": {
            "x": 2560,
            "y": 0
        },
        "priority": 1,
        "rgbrange": 0,
        "rotation": 1,
        "scale": 1,
        "vrrpolicy": 2
    }
]

At the end of the first half it says X 0 and Y 160, which is not good.

The longer version also has the data of the internal monitor.
Now, the external monitor has a Y-size of 1440 pixels, the internal one has 1600 pixels vertically. Difference is 160, exactly what it says in the file for the Y coordinate.

Although your idea to solve it is not the way I would like to go, I do think I will implement it until somebody comes along and has a real solution to why the monitors are off 160 pixels.

I have tried using Wayland but I gave up on that. Although it looks pretty good I can notice some smal delays when playing videos, the whole system is looking tired. Also, when I move the mouse cursor over for example the KDE menu I see trails appearing. They do go away by themselves after a few seconds, but they are not supposed to be there.
I certainly hope Fedora will not kill X11 before Nvidia and Wayland really work together.

I hope I made the situation clear so maybe you can also benefit from it.
Thanks for helping me.

The second one is the real one. I’m not sure what the first one is.

The first one shows the monitor connected to HDMI-1. The second shows it connected to HDMI-0. Did you change which connector it was on at some point?

No. That isn’t what you want. That is the coordinates of the top left. You wanted the bottoms aligned.

Correct. That is why the second file is doing what you said you want: Make the tops differ by 160 in order to make the bottoms agree.

Anyway, what I wanted to see was what changes in those (or other) files when the problem occurs.

But so far as the work around to fix it when it fails, I think you can fix the problem by restoring that second file before (or early during login). I don’t know if there is a way to get that correction recognized without logging in. Obviously the display settings GUI can do that, but then I don’t know how to make it do that without effort inside the GUI, nor do I know how to do what it does but without it.