Xorg 4K Hell
So I got a new 4K monitor and wanted to use it with Linux.
Easy enough under KDE, just set the scale factor, fiddle with font sizes a bit, and it just works. However, try adding a secondary monitor with different DPI and you’re in a world of weird hacks.
- KDE does not support mixed DPI under X11
- KDE on Wayland is still broken and lacks important features
- Gnome might work, but I hate Gnome
After some experimentation, I came up with the following script:
#!/bin/bash
sleep 5
xrandr --output HDMI-1 --off
xrandr --output HDMI-1 --auto --scale 1.55x1.55 --right-of DP-2 --rotate left \
--output DP-2 --scale 0.9999x0.9999
- I have two screens, main at DP-2 and secondary at HDMI-1.
- The secondary screen must be turned off first, otherwise KDE does not detect the change and draws the wallpaper only on half of the screen.
- I configured KDE to show correctly on the 4K screen, effectively upscaling the UI, so the side screeen had to be scaled down.
1.55x1.55
is the scaling factor, bigger number means smaller content.2x2
would be ideal to get somewhat crisp rendering, but I use 150% scaling in KDE, not 200%. The result is not pixel-perfect, but it’s better than having everything humongous. - My mouse cursor started flickering after scaling the side screen (I have Intel graphics with i915). Adding
--scale 0.9999x0.9999
fixed it. This weird hack is from Stack Overflow.
I run the script from KDE autostart (Settings -> Startup and Shutdown). The sleep is needed, it wouldn’t work without the delay; it might be shortened though.
I hope to find a less awkward solution, but it’s good enough for now.