Description:
This guide should be able to make GDM (Gnome Display Manager) choose Xorg server layout at startup, based on what you have connected to your VGA port. For instance, if you have a laptop it can automatically start X with a dual monitor setup if an external monitor is connected to the VGA port.
How it works:
We create a wrapper script that GDM uses to start X. The script utilizes ddcprobe to scan the device connected to the VGA port and find it's eisa identifier, which is given to X as the server layout to use. The script makes sure that there exist an identical layout identifier in xorg.conf, otherwise X is started with the default layout.
Note: I have not been able to find much information about ddcprobe. I chose the eisa entry as the identifier based on my very limited range of monitors I connect to my laptop, as it existed and had a unique value for each of them. It shouldn't be a problem to use some other entry of ddcprobe as a replacement, just replace every occurence of "eisa" with another entry name in the startx-custom script below.
Credits:
- This is basically mfremont idea from this post, I just modified it a bit (and wrote this guide
). - Joseph Brown for the idea to use ddcprobe to scan the VGA port.
Prerequisites:
- Server layouts in xorg.conf for whatever you want to connect to your computer. This is actually not a real prerequisite as the default server layout will be chosen if the connected device is unrecognized but without them this guide is pretty pointless.
- According to the documentation I found, ddcprobe should work on i386 and powerpc architectures and be able to scan VGA, DVI and HDMI connectors. However, this is only tested on an i386 architecture with a VGA port.
- GDM as display manager, which probably means you're running Gnome. I'm sure this can be done with other display managers too, but this guide will describe how to do it with GDM.
This is tested on Ubuntu 7.04 (a.k.a. Feisty Fawn) Desktop Edition (32bit), with an Intel Mobile 945GM Express chipset laptop.
Uninstallation:
Revert gdm.conf-custom to it's original state (preferably from a backup made).
Support:
I offer no support for this guide and it is to be used at your own risk! I will however try to answer the questions I can if you should post any below.
The Guide:
Ok, with all that out of the way, lets begin the guide 
First off, we need to install the xresprobe package if you shouldn't have happened to installed it earlier.
Code:
$ sudo apt-get install xresprobe
This could be a good opportunity to try ddcprobe and see if you have an eisa entry. If so, that should be the name of the server layout for your current setup.
A sample of the output could look like this:
Code:
id: 1514
eisa: AUO1514
serial: 00000000
manufacture: 1 2005
input: analog signal.
screensize: 26 16
gamma: 2.200000
dpms: RGB, no active off, no suspend, no standby
dtiming: 1280x800@59
monitorid: AUO
monitorid: B121EW01 V5
This is (part of) the output for my setup when I have nothing connected to the external VGA port. Notice that the eisa entry is "AUO1514", a string that changes to "DEL700c" (along with a lot of other changes in the output of ddcprobe) when I connect my desktop monitor to the VGA port and restart the computer. In xorg.conf I have server layouts accordingly:
Code:
Section "ServerLayout"
Identifier "AUO1514"
single monitor layout options...
...
EndSection
Section "ServerLayout"
Identifier "DEL700c"
dual monitor layout options...
...
EndSection
Next we should create the wrapper startup script for X. You can name it anything you want but this guide will assume it has the full path /etc/gdm/startx-custom. The guide also assumes you have gedit as your favorite editor, but you can of course use whichever you like.
Code:
$ sudo gedit /etc/gdm/startx-custom
Copy and paste the following into the file.
Code:
#!/bin/sh
# Custom script to start X for GDM with the ability to choose server
# layout as the eisa entry of ddcprobe
# Path to xorg.conf
XORG_CONF=/etc/X11/xorg.conf
# Find the current eisa entry of ddcprobe and write it to
# /var/log/gdm/custom
EISA_ENTRY=`ddcprobe | sed -n 's/eisa: //p'`
echo "eisa entry: $EISA_ENTRY" > /var/log/gdm/custom
# Check if the eisa entry is a defined server layout in xorg.conf
# (otherwise X will be started with the default layout)
LAYOUT=""
if [ -f $XORG_CONF ]; then
if test `sed -n '/section "serverlayout"/I,/endsection/Is/^[ \t]*identifier[ \t]\+"\(.*\)".*/\1/Ip' $XORG_CONF | grep -c -x $EISA_ENTRY` -eq 1; then
LAYOUT="-layout $EISA_ENTRY"
else
echo "did not find $EISA_ENTRY in $XORG_CONF, using default layout" \
>> /var/log/gdm/custom
fi
else
echo "$XORG_CONF does not exist" >> /var/log/gdm/custom
fi
# run the X server with the eisa entry as layout (if it was defined in
# xorg.conf)
exec /usr/X11R6/bin/X $LAYOUT $*
The basic user shouldn't need to modify this script, but since I can count the number of scripts I've created on one hand I might be wrong
If you should have changed anything in your setup (such as the location of your xorg.conf file), I assume you know Linux sufficiently well to change my script too!
Be sure to make the script executable.
Code:
$ sudo chmod u+x /etc/gdm/startx-custom
We need to tell GDM to use our new wrapper script. This can be done in /etc/gdm/gdm.conf-custom with a [server-Standard] section that will override the one in /etc/gdm/gdm.conf. First we'll make a backup which can be used to revert GDM to it's original state.
Code:
$ sudo cp /etc/gdm/gdm.conf-custom /etc/gdm/gdm.conf-custom.backup
$ sudo gedit /etc/gdm/gdm.conf-custom
Append the following to the end of this file.
Code:
[server-Standard]
name=Standard server
command=/etc/gdm/startx-custom -br -audit 0
flexible=true
You should make sure that this is just a copy of what is in /etc/gdm/gdm.conf with the command entry replaced with the path to our wrapper script (but with the same arguments). While you're at it, check to see that the original command, which we substituted for the path to our wrapper script, is the same as the one at the end of that script, i.e. /usr/X11R6/bin/X.
This should be all the modifications needed. What's remaining is to create server layouts for all setups you may have with identifiers according to the eisa entry in ddcprobe. To aid in this task is the log file /var/log/gdm/custom, which should contain the eisa entry found at startup and a note if it was not found as a server layout in your xorg.conf.
I hope this will work for all of you! I think of this as a small payback to the Ubuntu community, so it would be a shame otherwise
. Let me know if you have any use of it,
Regards Mattias
Bookmarks