I've installed Xubuntu 19.04, and to account for my laptop's screen resolution, in /etc/lightdm/lightdm.conf I've added the line

xserver-command=X -dpi 166

The result is that XFCE panel, terminal and other GTK2 and GTK3 programs take on the correct font sizes (the same as if I had set Custom DPI setting in AppearanceFonts to 166), but all the others like e.g. Yakuake still see 96 DPI. Moreover, if I try xdpyinfo, I do get this 96 DPI:

$ xdpyinfo | grep dot
  resolution:    96x96 dots per inch

Also, if I tick and untick back the Custom DPI setting option, the fonts shrink back in XFCE too (apparently, DPI gets re-queried from X server).

So I suspect that, during session startup, some entity changes the screen DPI setting as if by running xrandr --dpi 96. If I manually run xrandr --dpi 166, programs start behaving correctly.

I'd like to find out what exactly entity is doing this, so as to fix this at the core instead of adding post-startup workarounds. How can I find it?

  • That's an ugly story (read towards its end about Xft.dpi and other workarounds). If you're NOT using multiple monitors with diverse resolutions, you can put this in your ~/.xsession or other startup script (depending on your config): xrandr --fbmm "$(xrandr | sed -n 's/.* \([0-9]*\)mm x \([0-9]*\)mm.*/\1x\2/p')"; xdpyinfo | sed -n 's/.*x\(.*\) dots per inch/Xft.dpi: \1/p' | xrdb -merge -nocpp
    – mosvy
    Mar 19, 2020 at 8:27
  • @mosvy that's exactly what I'm trying to avoid: workarounds. Xorg is already starting with correct DPI (I've checked that by startx /usr/bin/xterm -- -dpi 166, as well as by the default font sizes in XFCE). It's just some bad X client that resets it to 96.
    – Ruslan
    Mar 19, 2020 at 8:37
  • I'm using my own wm (not some fancy DE), and I cannot check it just know, but I think that gnome or kde may reset the display resolution (using xrandr) to match Xft.dpi, which they assume that it "should" be 96 dpi if not set.
    – mosvy
    Mar 19, 2020 at 8:40
  • @mosvy OK, running xrdb -merge -nocpp <<< 'Xft.dpi: 166' results in Yakuake having larger fonts after xfce4-session is run, but xdpyinfo still outputs the reset value of 96, and ticking&unticking Custom DPI setting in XFCE Appearance dialog still shrinks XFCE fonts. Same with the case when I force xrandr --fbmm as you suggested.
    – Ruslan
    Mar 19, 2020 at 9:13

1 Answer 1


Thanks to comments by @mosvy, I've found that the culprit is xfsettingsd. In particular, its xfce_displays_helper_normalize_crtc function contains this arbitrary hard-coded choice of 96 DPI:

    /* The 'physical size' of an X screen is meaningless if that screen
     * can consist of many monitors. So just pick a size that make the
     * dpi 96.
     * Firefox and Evince apparently believe what X tells them.
    helper->mm_width = (helper->width / 96.0) * 25.4 + 0.5;
    helper->mm_height = (helper->height / 96.0) * 25.4 + 0.5;

After I stubbed this function away in the binary by replacing its first byte with 0xC3 (x86/x86_64 RET instruction), I no longer have 96 DPI forced on me.

This is not a fully long-term solution though, because an upgrade can overwrite this file, so I either have to hold xfce4-settings package (by apt-mark hold xfce4-settings), or do something else to avoid this misbehavior.

  • You can also use a LD_PRELOAD hack to override XRRSetScreenSize. See this old answer for an example, including for how you could sneak LD_PRELOAD accross ssh-agent in the /etc/Xsession.d startup scripts. Yes, I know, that's not much better ;-)
    – mosvy
    Mar 19, 2020 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.