I am relatively new to Linux/Ubuntu and am having a very anoying problem that seams to have been around in Ubuntu for a long time based on the google results I got when researching but all solutions seem to be adhoc and half assed.
My PC has an internal audio device and is connected to my TV via HDMI. The PC is being used as an HTPC so it should typically be using the HDMI device when it is available.
My audio output device is set to HDMI on boot with a startup application command in the GUI.
When the TV is turned off or goes to sleep the audio device automatically switches the internal audio device. This is to be expected as the HDMI device no longer exists to the computer. When the TV is turned back on the audio device in use remains as the internal audio device and I must manually change the device back to hdmi in either the Ubuntu sound settings or in using pactl in the terminal or by restarting.
This problem is frustrating, very anoying and from my research has been a problem for years in multiple distributions.
Is there a way for to have Ubuntu (or a 3rd party application) automatically manage the audio output device based on a hierarchy of priority which is reassessed whenever an audio device is added or removed from the system?
I am looking for a simple and persistant solution that won't be undone or require user action on reboot.
Something like this should be available by default for Ubuntu desktop distributions and would be valuable for video output, audio output and audio input given that it is commonly used on laptops that frequently have devices added and removed.
Thanks for the help.