Detecting Dual Displays
Posted by ubuntufan on October 6, 2006
So I installed Ubuntu 5.10 breezy badger because that was the media that I had. It picked up all of the hadware on my Thinkpad T40 by default. I was totally stoked. I tweaked things for a few days before thinking about trying to get dual displays working. I have read that others have done it with a pc but not a laptop. After some googleing, I found some references to folks that had it working on various Thinkpads, so I sat down to try and figure it out.
I will post my xorg.conf file some other time as I want to devote some time to explaining the different sections of the file and what they do. Today I want to go over how to detect if an external display is present and use the correct xorg.conf file and profile. I’m sure that there are many ways to skin this cat but this one works for me.
# determine whether an external display is attached
#cp /etc/X11/xorg.conf /etc/X11/xorg.conf.pre-local
if /usr/sbin/ddcprobe | grep -q “analog signal”; then
echo “External Display attached.”
# set external display as exclusive primary
# cat /etc/X11/xorg.conf.pre-local | sed ’s#”Single”#”Single,Reverse”#g’ > /etc/X11/xorg.conf
cp /etc/X11/xorg.dual.conf /etc/X11/xorg.conf
else
echo “Using build-in LCD.”
# set build-in LCD as exclusive primary display
# cat /etc/X11/xorg.conf.pre-local | sed ’s#”Single,Reverse”#”Single”#g’ > /etc/X11/xorg.conf
cp /etc/X11/xorg.conf.orig /etc/X11/xorg.conf
fi
Copy and past the above code into a file and name it xorg.conf_switcher.sh (or whatever you want). Place it in your /etc/init.d directory. Don’t for get to issue a sudo chmod +x /etc/init.d/xorg.conf_switcher.sh command.
Ok, so what does it do? Well, ddcprobe is a neat little utility that will return cool information about your video chip, monitor(s) etc. What we’re doing here is looking for the term “analog signal” . If it’s there the xorg.dual.conf file gets copied over xorg.conf otherwise xorg.conf.orig gets copied over. I know there’s a way to specify which xorg.conf file to use at launch but this works for me. Hope this helps.
Feel free to let me know what you think and if there are ways to improve on this. I’m really liking my new Ubuntized T40. Oh, I did do a distro upgrade to 6.0.6 and it was flawless.
Dale
Posted in displays, xorg | 1 Comment »










