X11 DPI information retrieval
This is a small C program that retrieves all information about DPI (dots per inch) of the available displays in X11. Information from both the core protocol and the XRANDR extension is presented. Xinerama information (which lacks physical dimensions, and is thus not directly useful to determine output DPI) is also presented. If an XSETTINGS daemon is found, the reported (scaled and raw) Xft/DPI value is presented.
(Limitation: XSETTINGS is currently only show for Xlib, not xcb.)
From the retrieved information,
xdpi will also compute (and present)
“proposed” per-monitor/per-output UI scaling factors, assuming a reference 96
DPI. Each scaling factor is computed as a single-precision floating-point
integer, and four values are shown:
- the floor (largest integer no larger than),
- the value itself,
- the rounded value (closest integer),
- and the ceiling (smallest integer no smaller than).
For each monitor/output, both the native scaling factors (based on the reported DPI) and the prorated factors (which take into account the ratio of the core DPI to the primary output DPI) are shown.
Finally, to improve the usefulness of
xdpi as a debugging tool, we also show
the content of the following known-relevant environment variables,
All of the code is licensed under the Mozilla Public License, version 2.
LICENSE.txt for details.
The program currently accepts no options.
You will need a compiler supporting C99, and development files for Xlib, and the XRANDR and Xinerama extensions.
For xcb support, you will also need the development files for xcb-xrandr, xcb-xinerama and xcb-xrm.
If you do not have xcb or your xcb version is too old, you can compile without xcb support by running
Why both Xlib and xcb?
Mostly, because I wanted to have a look at xcb and how different it was from Xlib. My usage is probably imperfect, but it does show how much more complex fully taking advantage of the asynchronous nature of the X11 protocol (which is what xcb is all about) is.
A simple program to illustrate how Qt 5.6 and higher handle DPI
information depending on the application settings
Qt::AA_DisableHighDpiScaling can be
found in the
Build it with
qmake && make
and then run it with
qmake by defaults builds against Qt4, run