I've not actually used it myself, but udev can be used to run scripts when particular devices are plugged in, so you may be able to configure it to spot your external display being plugged in.