I've got a MacBook Air that I am regularly plugging an external display in and out of. If you plug in a display when your MacBook is sleeping or turned off there are (typically) no problems. However, if your MacBook is on when you attempt to plug in an external display, it never automatically registers that a new display has been connected and therefore never turns it on accordingly. Insert expletive here. Yes Virginia, Mac OS X does have its baffling quirks and bugs.
In order to fix you have to manually go to System Preferences each time an external display is connected, go into the Displays preference pane, and then manually click on the "Detect Displays" button. Even worse, if you have an external display set as the main display and you unplug said external display you're left fumbling around in the dark bringing up the system preferences with keyboard shortcuts; Alfred's "Displays" shortcut helps get a little further along but still… Ack!
Instead of ranting further, I present my solution: "Alfred! Fix my displays!"
- What?! You don't use Alfred yet? Download Alfred here
- What?! You're not using the Alfred PowerPack yet? It's not necessary for this script, but just get it anyways: Download the Alfred Powerpack here
- Download the "Detect Displays" Alfred extension via the link below
Now, whenever you need to give your MacBook/MacBook Air/what-have-you a kick in the virtual desktop pants, just use Alfred to run the "fix display" keyword and you'll no longer be "plugging it in wrong" ;-)
Full credit goes to Ravi K. Udeshi for the original applescript that can be found at http://raviudeshi.com/2011/03/automatically-detect-displays