Toggle Dashboard Widgets Location when External Monitor Connected

Hey all! I have a Macbook Pro (10.6.7) and a 24" external monitor at work. Every night I disconnect the external monitor and take the Macbook home. When I activate Dashboard while the external display isn’t connected it repositions all of my widgets to ensure they’re all viewable. Completely understandable and logical as to why Apple does this, but the problem is when I return the next day and hook up the monitor again my widgets are still clustered together on the Macbook’s display. I’m trying to toggle between the two Dashboard layouts depending on if the external monitor is connected.

I’ve discovered that making a backup of ~/Library/Preferences/com.apple.dashboard.plist once I have the widgets arranged how I want across two displays then replacing the modified single display file with the dual display plist backup repositions my widgets the way I want. However I’d like a nice clean way of doing this, automatically running it when an external display is connected. This is my first attempt at AppleScript but once I can trigger a script when a monitor is detected I can achieve what I want to. Even get fancy and have different widgets display depending on the display(s) I’m using, but I guess I gotta learn to walk first :smiley:

So summarizing:

Call event handler on connecting external display
Copy com.apple.dashboard.dual.plist to ~/Library/Preferences/com.apple.dashboard.plist

Detect disconnecting external display
Copy com.apple.dashboard.single.plist to ~/Library/Preferences/com.apple.dashboard.plist

Any thoughts on how to ‘listen’ to detect an additional display is connected? Are there potential repercussions of going about it the way I’m describing? Any better ways?

Thanks for any input!