You are not logged in.

#1 2021-11-16 07:10:39

lfitzgerald
Member
Registered: 2021-07-16
Posts: 175

External monitor with different DPI - what to put in ~/.Xresources?

My laptop screen is 2560x1440 and comes out to about 210 dpi. I therefore have "Xft.dpi: 210" so that GUI programs like Kate will scale themselves up. This seems to work well enough when using just the laptop. I don't have the DisplaySize set in /etc/X11/xorg.conf.d/ - it didn't seem to do anything whether I comment it out or not, so I left it out.

The problem is with my external monitor, which is 1920x1080 and 92 dpi. Since Xft.dpi is set to 210, many things (like fonts in browser) end up larger on the external. But if I change Xft.dpi back to 92, then my laptop will have small fonts now. Is there not a way to set Xft.dpi per-monitor, or is there some other way to solve this problem?

Offline

#2 2021-11-16 07:32:02

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,200

Re: External monitor with different DPI - what to put in ~/.Xresources?

Drive the laptop at a lower resolution (and DPI), upscale the external monitor (eg. x2) or pick an average DPI.
X11 only supports one global DPI value, https://wiki.archlinux.org/title/HiDPI# … e_displays

Offline

#3 2021-11-17 07:59:45

lfitzgerald
Member
Registered: 2021-07-16
Posts: 175

Re: External monitor with different DPI - what to put in ~/.Xresources?

I'm already using that scaling trick - I was looking for a way to actually set different DPIs for each monitor. Sounds like that's not possible with Xresources.

Offline

#4 2021-11-17 08:04:18

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,200

Re: External monitor with different DPI - what to put in ~/.Xresources?

That's not possible w/ X11 and not usably implemented in most toolkits either.
(Wayland compositors as of recent typically use MSAA ie. they render everything at the big DPI and downscale the buffer for the smaller DPI)

Offline

#5 2021-11-17 14:38:51

ayushnix
Member
From: Mumbai, India
Registered: 2021-11-14
Posts: 9
Website

Re: External monitor with different DPI - what to put in ~/.Xresources?

You can achieve this using autorandr but this would work only if you use one display at a time, not both. You can keep your laptop in clamshell mode (docked) and use your external monitor with a specific DPI. When you use your laptop display, a different dpi can be applied.

Using a wayland compositor like sway will let you enable different scaling for different displays but if you enable fractional scaling, you might notice a subtle loss of quality in fonts and a slightly higher input latency.

Offline

#6 2021-11-18 17:35:19

lfitzgerald
Member
Registered: 2021-07-16
Posts: 175

Re: External monitor with different DPI - what to put in ~/.Xresources?

seth wrote:

That's not possible w/ X11 and not usably implemented in most toolkits either.
(Wayland compositors as of recent typically use MSAA ie. they render everything at the big DPI and downscale the buffer for the smaller DPI)

Seems like migrating to wayland will be the (eventual) long term solution for me... Unfortunately polybar doesn't support wayland yet so I'd have to figure out what to do with it first.

ayushnix wrote:

You can achieve this using autorandr but this would work only if you use one display at a time, not both. You can keep your laptop in clamshell mode (docked) and use your external monitor with a specific DPI. When you use your laptop display, a different dpi can be applied.

I already use autorandr, but how does it set DPI? Beyond the --scale parameter that was mentioned already, I was not aware of autorandr setting DPI. Or are you saying to set Xft.dpi as if I was using the external only, and just ignore everything being the wrong size on the laptop screen?

Offline

#7 2021-11-18 17:45:09

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,200

Re: External monitor with different DPI - what to put in ~/.Xresources?

The suggestion is that autorandr can juggle the DPI on your behalf, but not that it can provide different DPIs at the same time (what's not possible)
The wayland approach isn't really much different from the --scale solution.

Offline

#8 2021-11-18 18:11:39

lfitzgerald
Member
Registered: 2021-07-16
Posts: 175

Re: External monitor with different DPI - what to put in ~/.Xresources?

seth wrote:

The suggestion is that autorandr can juggle the DPI on your behalf

Do you mean something like using one of its hooks to modify ~/.Xresources every time it switches, or is there some more integrated autorandr feature?


but not that it can provide different DPIs at the same time

I gathered that - I was just wondering how autorandr can set DPI even if it's universal across screens.

The wayland approach isn't really much different from the --scale solution.

Well the hope is that it does a better job of scaling. I mean the --scale would be a perfectly fine solution if it didn't look so blurry at some scale factors.

Offline

#9 2021-11-18 18:33:45

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,200

Re: External monitor with different DPI - what to put in ~/.Xresources?

Idk what ayushnix meant to say - but ideally you'd not need to specify the resolution in xrdb anyway (shouldland scenario, I guess)
The scaling quality comes down to the used algorithm - there're naiv, fast and pretty ones. The pretty ones obviously take more hardware power hmm

Having the clients render everything at multiple DPIs is bad as well (because the content rendering of eg. browsers can be horribly expensive) so you'd have them to re-render whenever the window changes the output and either scale or double-render output/dpi intersecting windows (what also requires the clients to be able to render at different DPIs itfp…)

Offline

#10 2021-11-20 17:14:42

ayushnix
Member
From: Mumbai, India
Registered: 2021-11-14
Posts: 9
Website

Re: External monitor with different DPI - what to put in ~/.Xresources?

lfitzgerald wrote:

Do you mean something like using one of its hooks to modify ~/.Xresources every time it switches

Yes, that's what I meant. Well, not exactly modifying .Xresources but merging the relevant value of Xft.dpi in xrdb whenever you switch from one display to another.

Create profiles using autorandr for your laptop monitor and external monitor. Then create a postswitch file in each of them which contains something like

$ cat .config/autorandr/external-monitor/postswitch
#!/bin/sh

echo "Xft.dpi: 144" | xrdb -merge
echo "*dpi: 144" | xrdb -merge
i3-msg restart

Another postswitch file can be created for a laptop display with different Xft.dpi values.

Again, this works only if one display is active at a time. AFAIK, Xorg can't use multiple displays with different DPI values at the same time. Wayland can do that but it comes with its own issues.

Offline

Board footer

Powered by FluxBB