All I need is a way to:
1. Automatically detect when HDMI is connected
2. Switch to HDMI audio, basically simulate opening the sound settings and clicking on HDMI out
3. Switch back to laptop speakers when HDMI is unplugged
What event is triggered when an HDMI cable is plugged in, and would I be able to tie into it? I've checked dmesg and found nothing useful (as far as I could tell).
I found this, which looks like what I want, but it doesn't work for me because I have no /sys/class/drm directory. This is an updated version of the script that does some extra stuff, but it's still based on that same /sys/class/drm directory.
This post from 2010 provides a script that can be bound to a keyboard shortcut, but I want it to be automatic. Apparently it doesn't work on 12.04 anyway, but user psmbfuer posted his own version of the script 1 day ago (as of this post) that apparently does. I haven't tried it, becauselists my single soundcard as 2 different cards, one for HDMI and one for the laptop speakers.Code:pactl list cards
Any suggestions for approaching this?