Best practice: Working with different screen resolution (FHD and 4K)

I gave up with 4K (auto-)settings. QHD (2560x1440) is the best compromise for me - my Qubes OS setup. QHD 27" works fine for me without modifying the scaling settings and due to the limitation of HDMI 2.0 (4K max. 60 Hz) I have 144 Hz available.

Nevertheless, I would like to drop some notes for someone who might want to follow up on this topic.

  • Librewolf (Firefox) fix for 4K:
    open a tab: about:config and set config parameter
    layout.css.devPixelsPerPx to 2

  • My script I used; auto-run during startup
    Issue: xrandr needs access to the X server (it works when you open a terminal and launch the script, but not automatically without a terminal opened)

# auto display scaling for 4K monitor (3840x2160; 16x9)
# prerequisites  (for *x2160 pixel detection):
#   - no pivot setup
#   - if notebook, then HD notebook and 16:9 ratio
DPI_dectection=$(xrandr | grep connected | grep -v disconnected)
DPI_factor="96"
DPI_scale="1.5"

if [[ ${DPI_dectection} == *"x2160"* ]]; then
    export QT_AUTO_SCREEN_SET_FACTOR=0
    export QT_SCALE_FACTOR=${DPI_scale}
    export QT_FONT_DPI=${DPI_factor}
    export GDK_SCALE=${DPI_scale}
    export GDK_DPI_SCALE=1
    gsettings set org.gnome.desktop.interface text-scaling-factor ${DPI_scale}
 else
    export QT_SCALE_FACTOR=1
    export GDK_SCALE=1
    export GDK_DPI_SCALE=1
    gsettings set org.gnome.desktop.interface text-scaling-factor 1.0
fi

An alternative, which I did not test (credits go to @solene)

One method could be to make a script in dom0 that could figure if you need 4k or not, then in the rc.local script, you call it using qrexec to know if you are using 4K, then you could overwrite variables in /etc/profile instead of exporting, that should work IMO (if rc.local starts before X)

1 Like