This has probably been asked to death around here, but I could never get to a final solution (probably for good cause).
Anyway, is there any way in Ubuntu (I use Ubu
The jack detection API is (here or here):
snd_jack_new — Create a new jack snd_jack_set_parent — Set the parent device for a jack snd_jack_report — Report the current status of a jack