Saturday, April 11, 2015

Manually Fixing Multiple Screens with Different DPIs in Linux

Step 1:

Set the system wide DPI to a comfortable level for your highest resolution screen, using X Resources. There is a DPI calculator here.

Step 2:

With the DPI set in step 1, work out what scaling is comfortable on your secondary screen. You can do this by adjusting the layout.css.devPixelsPerPx Firefox setting or with xrandr, eg:

xrandr --output HDMI1 --scale 1.3x1.3

Step 3:

Update 11-Nov-2016: It appears that you no longer need supply the --fb parameter, iirc the previous symptom was only being able to access a certain area of the lower DPI screen.

Calculate the total screen size for the xrandr --fb parameter. To do this multiply the x and y resolution values of your secondary screen by the scaling factor, and then add the primary value, depending on whether you have your screens left/right or above/below. In my case both my monitors are 1920x1080, my secondary monitor is scaled at 1.3 and I have my primary monitor below my secondary monitor, so my total screen size is 1920 * 1.3 x 1080 * 1.3 + 1080, or 2496x2484.

Step 4:

Update 11-Nov-2016: There is a script here which will do these calculations for you. Obviously you may want to change the scale factor of 2.

Calculate the position of your two monitors. My primary monitor is centred below my secondary monitor. So my secondary monitor is at 0x0 and my primary monitor is at (1920 * 1.3 - 1920) / 2 x 1080 * 1.3 or 285x1404. 

Step 5:

Put the above values into xrandr:

xrandr --output HDMI1 --scale 1.3x1.3 --mode 1920x1080 --fb 2496x2484 --pos 0x0
xrandr --output eDP1 --scale 1x1 --pos 285x1404

With thanks to this SE post.

Udate 09-Aug-2017

Step 6:

Out of the blue I started getting:

xrandr: screen cannot be larger than 8192x8192 (desired size 12800x2880)

To fix this I created:

/etc/X11/xorg.conf.d/85-screen.conf

Section "Screen"
        Identifier      "Default Screen"                                       
        DefaultDepth    24                                                     
        SubSection "Display"
              Virtual 12800 12800
        EndSubSection
EndSection

This didn't work when it was ordered after the monitor section.

2 comments:

  1. Great man!
    This is the only working solution aroung. Thanks for sharing.

    Anyway the --scale option seems to blur a bit the text did you find something to improve sharpness?

    ReplyDelete
  2. I know what you mean about the blurriness, and no I haven't found a solution. I wonder if blurriness occurs when you don't scale by whole numbers. To be honest I haven't looked into it further because I don't use this solution because my screens aren't very high DPI, all I do is use Firefox's scaling option which works well and doesn't have the blurriness issue.

    ReplyDelete