Januar 26, 2022

Lenovo i3 multiscreen xrandr

So i wanted to to get a multiscreen setup to work with a lenovo laptop in a dockingstation (one external monitor connected via HDMI $EXT2 and one via VGA $EXT), so there is a total of three monitors (including the internal one $INT).

When changing the configuration via xrandr (e.g. enable two external ones and disable internal one) i faced the error configure crtc X failed and the configuration was not applied correctly.

Searching for xrandr configure crtc failed with three monitors brought up enough results, but none of the solutions (like specifying --crtc X) worked.

In some threads, arandr is suggested to explore options visually. Interestingly enough, arandr was able to switch to the desired configuration. When looking at the resulting xrandr command, i saw that it switched the configuration in multiple steps.

So it seems that xrandr cant switch three sources at once (not sure under which conditions) so the solution in my script was to:

  • enable one external monitor (and check if it worked)
  • if it worked, turn off internal monitor (avoids having no monitor active)
  • enable second monitor as well

The script then looks like this:

xrandr --addmode $EXT2 $EXTRES2 || exit 1
xrandr --addmode $EXT $EXTRES || exit 1
xrandr --output $EXT2 --auto --mode $EXTRES2 --primary --scale 1x1
ret_code=$?
if [ $ret_code -eq 0 ]; then
xrandr --output $INT --off
fi
xrandr --output $EXT --auto --mode $EXTRES --right-of $EXT2

One problem that was left was that the i3 tiling window manager would not put the i3status bar on the primary screen. Luckily i found the solution here, in ~/.config/i3/config add the line for tray_output

bar {
  status_command exec i3status
  tray_output primary
}
`