Display Switching ScriptPosted: 04.07.12
This is my script for detecting if an external monitor is plugged in, and, if so, making it primary. Add this to your startup applications and your desktop will automatically configure itself after you log in.
chdmi=xrandr | grep "HDMI1 connected"
if [ -n $chdmi ] ;
then xrandr --output HDMI1 --primary ;
Note that you can simply change HDMI1 to VGA1 or DVI1, according to what port you use for your external monitor.