I have a notebook (Lenovo Thinkpad T14) running Ubuntu 21.10 (and another similar one running Ubuntu 20.4) with Xfce4 (aka XUbuntu) and a Thinkpad USB-C docking station, to which I've connected two external screens. I'm using one of them in a vertical direction, the other one horizontally, in addition to the Notebook screen.
Unfortunately, each time I start the system (and occasionally also when I disconnect and then reconnect the docking station), the assignment of the screens to the display port numbers are different, and thus the previously saved screen arrangement does not work anymore. Some assignments I've found:
- vertical on DisplayPort-5, horizontal on DisplayPort-6
- vertical on DisplayPort-5, horizontal on DisplayPort-3
- vertical on DisplayPort-3, horizontal on DisplayPort-4
- vertical on DisplayPort-3, horizontal on DisplayPort-5
- vertical on DisplayPort-6, horizontal on DisplayPort-5
Once I even got a seventh display port, though that might have been when I tried out a second docking station in addition.
My current solution is to store a profile in the display settings (each time I hit a new one I didn't get before, I add it there).
When the screens are wrong after login:
- switch off the power (to screens and docking station), which disconnects all screens
- switch the power on again → then the "Screens" dialog pops up:
- try the buttons until one of them arranges the screens the right way
- If none of them fits, create a new setup (and call up arandr to get the names of the displays).
I recently found out that on my Thinkpad keyboard I can also use the Fn+F7 key to get the dialog, so I don't have to switch the power off and on.
Still, is there some way of automating this, so I get the screens arranged correctly without manual input each time?
Some details:
As an example, when I originally wrote the question, xrandr -q
printed this:
Screen 0: minimum 320 x 200, current 3000 x 1275, maximum 16384 x 16384
eDP connected 1280x720+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
1920x1080 60.05 +
1680x1050 60.05
1280x1024 60.05
1440x900 60.05
1280x800 60.05
1280x720 60.05*
1024x768 60.05
800x600 60.05
640x480 60.05
HDMI-A-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1 disconnected (normal left inverted right x axis y axis)
DisplayPort-2 disconnected (normal left inverted right x axis y axis)
DisplayPort-3 disconnected (normal left inverted right x axis y axis)
DisplayPort-4 disconnected (normal left inverted right x axis y axis)
DisplayPort-5 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 509mm x 286mm
1920x1080 60.00*+
1600x900 60.00
1280x1024 75.02 60.02
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
720x400 70.08
DisplayPort-6 connected 1920x1080+1080+195 (normal left inverted right x axis y axis) 531mm x 299mm
1920x1080 60.00*+
1680x1050 59.88
1280x1024 75.02 60.02
1440x900 59.90
1280x960 60.00
1280x800 59.91
1152x864 75.00
1280x720 60.00
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
640x480 75.00 72.81 66.67 59.94
720x400 70.08
DVI-I-4-4 disconnected (normal left inverted right x axis y axis)
DVI-I-3-3 disconnected (normal left inverted right x axis y axis)
DVI-I-2-2 disconnected (normal left inverted right x axis y axis)
DVI-I-1-1 disconnected (normal left inverted right x axis y axis)
So the screens were connected to "DisplayPort-5" and "DisplayPort-6".
I then switched off the computer, switched it on again, and the screens were messed up (overlapping view ports). xrandr -q
showed this:
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
eDP connected 1280x720+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
1920x1080 60.05 +
1680x1050 60.05
1280x1024 60.05
1440x900 60.05
1280x800 60.05
1280x720 60.05*
1024x768 60.05
800x600 60.05
640x480 60.05
HDMI-A-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1 disconnected (normal left inverted right x axis y axis)
DisplayPort-2 disconnected (normal left inverted right x axis y axis)
DisplayPort-3 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 509mm x 286mm
1920x1080 60.00*+
1600x900 60.00
1280x1024 75.02 60.02
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
720x400 70.08
DisplayPort-4 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
1920x1080 60.00*+
1680x1050 59.88
1280x1024 75.02 60.02
1440x900 59.90
1280x960 60.00
1280x800 59.91
1152x864 75.00
1280x720 60.00
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
640x480 75.00 72.81 66.67 59.94
720x400 70.08
DVI-I-4-4 disconnected (normal left inverted right x axis y axis)
DVI-I-3-3 disconnected (normal left inverted right x axis y axis)
DVI-I-2-2 disconnected (normal left inverted right x axis y axis)
DVI-I-1-1 disconnected (normal left inverted right x axis y axis)
So the screens are now recognized as "DisplayPort-3" and "DisplayPort-4", not 5 and 6 as before.
After triggering the screen setup dialog and choosing the correct one (vDP3+hDP4+laptop, the second custom one in the screenshot above), it shows this (I'm not sure whether it shows how one is rotated):
Screen 0: minimum 320 x 200, current 3000 x 1996, maximum 16384 x 16384
eDP connected 1280x720+1080+1276 (normal left inverted right x axis y axis) 309mm x 174mm
1920x1080 60.05 +
1680x1050 60.05
1280x1024 60.05
1440x900 60.05
1280x800 60.05
1280x720 60.05*
1024x768 60.05
800x600 60.05
640x480 60.05
HDMI-A-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1 disconnected (normal left inverted right x axis y axis)
DisplayPort-2 disconnected (normal left inverted right x axis y axis)
DisplayPort-3 connected 1080x1920+0+0 left (normal left inverted right x axis y axis) 509mm x 286mm
1920x1080 60.00*+
1600x900 60.00
1280x1024 75.02 60.02
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
720x400 70.08
DisplayPort-4 connected 1920x1080+1080+196 (normal left inverted right x axis y axis) 531mm x 299mm
1920x1080 60.00*+
1680x1050 59.88
1280x1024 75.02 60.02
1440x900 59.90
1280x960 60.00
1280x800 59.91
1152x864 75.00
1280x720 60.00
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
640x480 75.00 72.81 66.67 59.94
720x400 70.08
DVI-I-4-4 disconnected (normal left inverted right x axis y axis)
DVI-I-3-3 disconnected (normal left inverted right x axis y axis)
DVI-I-2-2 disconnected (normal left inverted right x axis y axis)
DVI-I-1-1 disconnected (normal left inverted right x axis y axis)