How can I run a script whenever I plug in an external monitor? [duplicate]

Possible Duplicate:
Reset Mac OS X Windows Position after de-attaching external monitor

I use my laptop at work, where I have a second monitor, and at home, where I don't. When I plug in the external display, I'd like the Mac to automatically run a shell script or AppleScript that will reposition a bunch of windows to their "standard" external-monitor locations. Is there any Apple Event or similar thing that can launch my scripts when I plug in a monitor? Alternatively, are there any utilities that specifically do this? I looked at Breeze, but it saves window state on an app-by-app basis, and doesn't detect monitors being plugged or unplugged.


Solution 1:

There is a piece of software called MarcoPolo that lets you execute various actions (including scripts) when the physical state of a box changes (you can switch on stuff like external power, external monitor, ambient light, time of day, attached drives, visible wifi networks, ip address, etc)