How to detect external monitor connection on laptop
I have a Lenovo T61p w/ NVIDIA FX570M GPU running Slack 12.2.
I sometimes have an external monitor connected, and like having it set up as a separate Screen in X (i.e. laptop DFP as :0.0 and external as :0.1).
I can do this no problem when the monitor is connected. Only trouble is that if the external monitor is not connected, X won't start unless I either change the default ServerLayout or pass a command-line option.
I'd like to have it automagically figure out whether or not to try and use the second screen.
As far as I can tell, X will not sequentially try ServerLayouts in the xorg.conf file until one works (which would be a really nice feature, IMHO).
So, is there a command that I can have startx (or similar) run to determine if anything is connected and then call X with the appropriate ServerLayout?
I've waded through the /sys and /proc directories, checked every logfile I can think of, and can't find anything that reports the connection status.
Thanks for any help!