Ask Your Question
1

How to set persistent DPI?

asked 2016-04-18 11:04:32 -0500

Dag gravatar image

I want to set the correct DPI for my display in Xorg, so that for example viewing a PDF at 100% is close to the true size in print, and mozmm in Firefox is close to a true millimeter. I wish I could make cm/mm/in in Firefox true to their names as well but it seems that can't be done except by pixel scaling with obviously poor results. But that's not what this question is about.

The problem is that while I have found some methods to change the DPI in Xorg, they don't stick! I have this

$ cat /etc/X11/xorg.conf.d/90-monitor.conf
Section "Monitor"
    Identifier "<default monitor>"
    DisplaySize 290 163
EndSection

Which correctly results in a 168x168 DPI when I log in, but it keeps getting reset to 96x96 seemingly randomly but possibly related to events like suspending, locking the screen, closing and opening the laptop lid, or connecting a second screen/TV via HDMI. When I notice this has happened (i.e., all the time), I fire up a terminal and run xrandr --dpi 168 and it's correct again. For a time. A frustratingly short time. Honestly I'm considering writing a script to run that xrandr command every second and autostart that on login, but seriously.

Note: I'm not asking about font scaling (which works independent of DPI) or about "HiDPI" window scaling (which would only work for my purposes if the DPI was a multiple of 96). My screen DPI is 168 but Xorg and GNOME and Firefox all insist on 96. As such, 100% zoom in Evince is really only 57%, for example. If I use "HiDPI" window scaling I can keep everything at 96 DPI but upscale it virtually to 192 DPI, but now 100% in Evince is closer to 114% and everything is much too big for my screen anyway. If I set a 1.75 font scaling factor then point sizes in FreeType and Pango are correct but it doesn't really affect anything else, not that it should. And when I set the correct DPI in Xorg or with XRandR it keeps sneaking 96 back in.

I've been fighting with this for a week now and apologize if my frustration is creeping through in my writing or if I've missed a relevant existing question here: I haven't found one anywhere on the Internet. Everything I find seems to be either about font scaling or HiDPI, or only relevant for old X servers (where you hand-write an xorg.conf) or setups that assume use of startx.

Can't I just tell X to calculate the correct DPI, or use the one I've calculated, and remember it? Pretty please?

Thanks

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-05-25 03:59:43 -0500

migle gravatar image

Your analysis is correct. This is extremely annoying. Just a few more facts, it's not X that messes up the DPI. X has it correctly and you can set it in xorg.conf as well. It's gnome that sets it to 96 on startup. You will have the right DPI if you use a different desktop environment.

I have worked around this issue by putting a desktop entry in ~/.config/autostart with Exec=xrandr --dpi 185 (in my case). This does it on boot. However, if you suspend the machine and then resume, gnome will set your DPI again to 96, and I can't see a clean solution around that, that's why I'm searching.

This is an extremely annoying design decision with gnome. It's virtually useless as well, because normal gnome applications don't need that value. We only need the right DPI setting for looking at printed pages.

I wish the gnome team knew how practical it is to have a ruler by your monitor when working on a paper and then just measuring stuff right in your monitor to then adjust margins, sizes, etc, knowing the amount that you want. With the design they chose, which is absolutely not relevant for HiDPI (as KDE shows), they rule out this use case that is so useful for some users.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-04-18 11:04:32 -0500

Seen: 1,857 times

Last updated: Apr 18 '16