Skip to content


Thinkpad T400 – switching monitors

With Ubuntu most of the Things work right out of the Box…. Once you solved the two graphic cards problem trough the BIOS (enable on card only!). I choose the internal intel graphics because it uses less power than the ati and has support for the RandR Extension. (Which comes in handy if you plug and unplug external monitors/projectors).

Problem is that you have to reconfigure (you can do clickingly in gnome) every time the monitor setup changes. Some problem appeared at work where i have a huge 1920×1200 screen. “Viewport is to small for both” it says. So no problem, i disable the laptop monitor and go with the external … so far so god. But in the evening i get lazy unplug my lap and go home… at home laptop screen is still disabled… black… no (comfortable) chance to switch it on again… Pretty annoying, i have to reconfigure before unplugging, disabling the external and enabling the internal again…

I don’t want to do that.

excursus: Viewport can be fixed like this, just add the following to your xorg.conf Screen section:

SubSection “Display”
Depth 24
# Just set it high enough for
# every combination of Monitors
# There is a known issue that DRI doesn’t work on pre-965 if maximum is larger than 2048×2048.
Virtual 2048 2048
EndSubSection

EndExcursus

So let’s start

First we need some info:

mp@mp-t400:~$ xrandr -q
Screen 0: minimum 320 x 200, current 3120 x 1050, maximum 3360 x 1200
VGA connected 1680×1050+1440+0 (normal left inverted right x axis y axis) 434mm x 270mm
1680×1050 60.0*+
1600×1024 60.2
1400×1050 70.0 60.0
1280×1024 75.0 60.0 60.0
1440×900 59.9
1280×960 60.0
1360×768 59.8
1152×864 75.0 75.0 75.0 70.0 60.0
1024×768 75.1 75.0 70.1 60.0
832×624 74.6
800×600 72.2 75.0 60.3 56.2
640×480 75.0 72.8 75.0 60.0 59.9
720×400 70.1
LVDS connected 1440×900+0+0 (normal left inverted right x axis y axis) 303mm x 190mm
1440×900 60.0*+ 59.9 50.0
1360×768 59.8
1152×864 60.0
1024×768 60.0
800×600 60.3 56.2
640×480 59.9

So here we see two outputs LVDS for the internal one and VGA for the external monitor.

LVDS is left of the VGA one. i configured this graphicaly (thanks to xrandr).

bildschirmfoto-bildschirmeinstellungen

(And yes my monitor at home has a different size than the one at work…). The above picture illustrates the manual fiddling arround i was complaining about :-D
I want to have the internal screen on the left because it’s size is unlikely to change and the viewport is counting from top-left… (had to switch to a above/under setting, more later)

If i unplug the external monitor i get the problem. Menus and the like keep sticking tho the now inexistant external screen… pretty annoying.

Now we come to the point why i want RandR Extension support for my graphics. With the xorg tool xrandr – i can now automatically configure my external screen on the Fly. Without restarting X.
As we know from the output before it has the identifier VGA. I now auto-detect the VGA Port with xrandr and set this monitor above the first one (only works if one is here of course :-D ): (PS: I choose above LDVS because mode DRI only support 2048 in width, and i want DRI for the Compiz crap)

$> xrandr –output VGA –auto
$> xrandr –output VGA –above LVDS

So that does the trick. i do not want to type that in every time, so i write a little script and bind it to a key a never use :-D

First the script in ~/scripts/detectvga.sh

#! /bin/sh

xrandr –output VGA –auto
xrandr –output VGA –above LVDS

Don’t forget to

$> chmod +x ~/scripts/detectvga.sh

Now let’s start that script with a special key. I use xbindkeys to do such tricks… (because it works for every windowmanager and it’s easy). First i need the keycodes:

$> xbindkeys -k

Keycode for F6 is “m:0×10 + c:72″

so i add the following to mi .xbindkeysrc

#automatic xrandr yai…
“/home/mp/scripts/detectvga.sh”
m:0×10 + c:72

FINISH!

More info:

$> man xrandr
$> man xbindkeys

Posted in *nix.

Tagged with , .


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. MP says

    I just realised that this Post is a huge mess. I will correct it sometime over the weekend. Enjoy. Questions are welcome.



Some HTML is OK

or, reply to this post via trackback.