Since it’s a bit hard to find out which part of all the “How do I do HiDPI on a Linux/BSD box with X11?"-lore you actually need to get a usable setup, I’ve collected all the things that I needed for getting that set up on my Dell XPS 13 7390.
Some of the sections below mention manipulating the file ~/.Xdefaults
. If you modify the file, the changes won’t become effective immediately. You can either reload the file with xrdb -load ~/.Xdefaults
or just restart your X11 session. If you only do the manual reload, already running applications won’t be affected.
Decide which DPI you want content to be rendered at. The default DPI that X11 assumes is 96, so if you want the content on your screen to be twice as large, set the DPI to 192 by adding:
Xft.dpi: 192
to your ~/.Xdefaults
.
The selected DPI should be an even multiple of 96 (which is the Low-DPI value that X11 uses by default), otherwise you may get weird scaling artifacts such as fuzzy fonts.
Add
QT_SCALE_FACTOR=0.5
to your ~/.Xsession
or shell profile to get proper scaling in QT applications like Virtualbox.
The dirty trick to get multiple screens with different DPI working at appropriate resolutions (similar to MacOS) is to set the DPI of all screens to the highest and scale screens with lower DPI so that they display their content at the right size.
In my example, I have two screens:
eDP-1
)DP-1
)The trick now is to render the content of the external display on a frame buffer twice as large as the display and “zooming out” the display so that it can display the complete frame buffer:
xrandr --output DP-1 --scale 2x2 --mode 1440x900
The other display needs to be moved to the side a bit so that they fit next to each other nicely:
xrandr --output eDP-1 --scale 0.999x0.999 --pos 2880x0
The weird scale for eDP-1
is because some GTK applications like Firefox and Chrome show a flickering cursor for 1x1 scaling.
This is only effective for the current session. I just stuck these commands in a shell script that I start when I connect the external screen. If you want to have this done automatically, my honest suggestion is to just start using Xfce as your desktop environment, since its screen setup comes with native support for multi-DPI setups.
The biggest benefit of a HiDPI display is the ability to use larger font sizes and get smoother rendering of text. Some applications are not smart enough to derive appropriate font sizes from the value of the Xft.dpi
value in the X resources, so you may need to adjust fonts to just use larger sizes. In my setup, this mostly applies to applications using “classic” X11 libraries for rendering text, such as Acme and dwm
.
Add
gtk-cursor-theme-size=48
to ~/.config/gtk-3.0/settings.ini
and restart GTK applications.
These are things like DWM, Acme, …
Add
Xcursor.size: 48
to your ~/.Xdefaults
.