- Digging up the past
- Happy Monkey
- So, who likes that new Y! nav bar on Flickr?
- Point Reyes
- A few handy git aliases
Polluting the internet since 2004
One of the things about having a laptop and continually connecting and disconnecting from an external display is having to tell the system to detect the external (and sometimes the internal) display so that both displays are running. Simply detecting displays doesn’t seem to be an easily scriptable system event. I finally got an AppleScript cobbled together so that I can simply launch this AppleScript from LaunchBar (you Quicksilver users can do the same thing).
This is based off of code that I’ve written as well as code that I found on Apple’s AppleScript mailing list and should be adaptable to most menu-bar items.
The key part that took a while to figure out in there is the delay right after the menu item click. The system just didn’t like everything happening so fast and on a whim I tried the delay and it worked.
This works with OS X 10.6 Snow Leopard. It seems that in every major release since about 10.4 Apple has changed something about the syntax for reaching menu-bar items so I don’t expect this to work on previous versions of OS X.
Update 2011-11-21: This script continues to work fine on Lion. For those that prefer a Gist to copy from, you can do that here.