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:


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

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