Switching of xorg.conf files at boot

The Intel graphics card in my laptop works well with Xinerama but has no direct rendering, when run that way. So, if I need/want 3D, or just want a single screen to avoid placements of windows on an unattached screen I have to change the /etc/X11/xorg.conf file...

Now, I wanted the least amount of meddling for this and created xorg.conf.single and xorg.conf.dual and let xorg.conf just be a symlink to one of them.
Still, since kdm is started automatically at boot, this is annoying because I have to switch to VT1, log in, change the symlink, restart the service, yadda yadda yadda.

However, there is /proc/cmdline, which gives the kernel paramaters given to the bootloader. Now create a second entry in Grub and amend a variable with a somewhat meaningful name (I just used monitorstate=external). The following will check the true/false condition of that variable and then changes the symlink accordingly. I just put this at the beginning of the start() function in the init script for xdm (/etc/init.d/xdm) and I now don't have to touch symlinks anymore.
This is an ugly, ugly hack...but it works for me.

state=`grep external /proc/cmdline | wc -l`
if [ $state  = "1" ]; then
  ln -sf /etc/X11/xorg.conf.dual /etc/X11/xorg.conf
else
  ln -sf /etc/X11/xorg.conf.single /etc/X11/xorg.conf
fi

posts: