Right now when I plug my HDTV into my laptop's HDMI input I have to run 'xrandr' for it to recognize the display and then manually switch the audio hardware selection.
Is there a way that Ubuntu can detect when the HDMI is plugged in and invoke a script that calls xrandr and switches the hardware and then does likewise when disconnected?