I’ve just bought a new 4k monitor, and everything is really small when using Ubuntu + i3, the scale doesn’t seem to be right in the two others monitors. The default DPI is 96, and i3 bar + mouse pointer seems ok on the 4k screen, but appears too big on the vertical monitors.

After some research and maths, here’s how I configured it so it’s a little bit easier on the eyes. I hope with some visuals, it’ll be easier to understand what’s going on.

References: (many thanks for the detail write up)

https://wilfredwee.github.io/entry/how-to-xrandr

https://blog.summercat.com/configuring-mixed-dpi-monitors-with-xrandr.html

Details:

2023-03-13-034148_2023x1353_scrot.png


#!/bin/bash
ms=1.5 # main scale
ls=2
rs=2

mw=3840
mh=2160
msw=$(echo "$mw * $ms / 1" | bc) # use bc to round the number
msh=$(echo "$mh * $ms / 1" | bc)

lw=1440
lh=2560
lsw=$(echo "$lw * $ls / 1" | bc)
lsh=$(echo "$lh * $ls / 1" | bc)

rw=1080
rh=1920
rsw=$(echo "$rw * $rs / 1" | bc)
rsh=$(echo "$rh * $rs / 1" | bc)

totalw=$(( msw + lw * ls + rw * rs ))
totalh=$(( lh * ls ))
fb="${totalw}x${totalh}"

mainmode=${mw}x${mh}
lmode="${lh}x${lw}"
rmode="${rh}x${rw}"

echo $fb
echo $mainmode
echo $lmode
echo $rmode

xrandr \\
  --output DP-4 \\
  --primary \\
  --mode $mainmode \\
  --fb $fb \\
  --rotate normal \\
  --scale "${ms}x${ms}" \\
  --panning "${msw}x${msh}+${lsw}+0" \\
\\
  --output DP-0 \\
  --rotate left \\
  --left-of DP-4 \\
  --mode $lmode \\
  --fb $fb \\
  --scale "${ls}x${ls}" \\
  --panning "${lsw}x${lsh}+0+0" \\
\\
  --output HDMI-2 \\
  --rotate right \\
  --right-of DP-4 \\
  --mode $rmode \\
  --fb $fb \\
  --scale "${rs}x${rs}" \\
  --panning "${rsw}x${rsh}+$((lsw+msw))+0" \\