Extended display with Ubuntu, xrandr 1.2 on i810 chips
Written on 29.10.07
Ok, Ubuntu's displayconfig is "sort of" broken. Wanting to put an external Philips monitor I had lying around for good use, I set out to configure my HP laptop, which has an i810 card, for extended display.
First things first, you'll need to do some changes to the Xorg configuration file:
sudo vi /etc/X11/xorg.conf
And add/change:
Section "Device"
Identifier "Intel Corporation 82852/855GM Integrated Graphics Device"
Driver "intel"
BusID "PCI:0:2:0"
Option "monitor-LVDS" "Generic Monitor"
Option "monitor-VGA" "VGA1"
EndSection
Section "Monitor"
Identifier "VGA1"
Option "RightOf" "Generic Monitor"
Option "Position" "1280 0"
EndSection
Section "Screen"
Identifier "Default Screen"
Device "Intel Corporation 82852/855GM Integrated Graphics Device"
Monitor "Generic Monitor"
DefaultDepth 24
SubSection "Display"
Depth 15
Modes "1280x768"
EndSubSection
SubSection "Display"
Depth 16
Modes "1280x768"
EndSubSection
SubSection "Display"
Depth 24
Modes "1280x768"
Virtual 2560 1280
EndSubSection
EndSection
Here's the deal, I'm trusting you to know your stuff and be able to pickup what needs to be added or changed. Put this script on your ~/bin directory (which probably is or should be on the $PATH):
#!/bin/bash
switch_on() {
EXTERNAL="`xrandr -q | grep '[^LVDS] connected' | cut -f 1 -d ' '`"
if [ -z $EXTERNAL ]; then
echo "No external monitors connected"
exit 1
fi
if [ -z $2 ]; then
MODE="--auto"
else
MODE="--mode $2"
fi
xrandr --output ${EXTERNAL[0]} --${1}-of LVDS $MODE
gconftool --type int --set /apps/panel/toplevels/top_panel_screen0/monitor 1
}
switch_off() {
EXTERNAL="`xrandr -q | grep -E '[^LVDS] (dis)?connected' | cut -f 1 -d ' '`"
for mon in $EXTERNAL; do
echo "Disconnecting: $EXTERNAL"
xrandr --output $mon --off
done
gconftool --type int --set /apps/panel/toplevels/top_panel_screen0/monitor 0
}
help() {
echo "`basename $0` on|off [left|right|up|down] [resolution]"
echo "Usage: on|off turns the external displays on or off, left|right|up|down control the position of the external monitor. Resolution is optional or must be something like WxH, e.g. 1280x768"
exit 1
}
case "$1" in
on)
case "$2" in
up|down|left|right)
switch_on $2 $3
;;
*)
help
;;
esac
;;
off)
switch_off
;;
*)
help
;;
esac
exit 0
When you plug your external monitor to your laptop, invoke the command: external-monitor on right and you should have an extended desktop. Invoke external-monitor off and it'll be turned off. I snooped on DBUS to check if HAL emitted some kind of signal to make all this automatic, but it doesn't so you'll have to run things yourself.
Other stuff I'm assuming: your external monitor has a maximum resolution of 1280x1024 and your laptop screen has a resolution of 1280x768. If any of them are able to handle higher resolutions, you'll need to change the Virtual values.