When I unplug the headphones, the sound device is set automatically to "Digital Output (S/PDIF)" instead of the "HDMI / Displayport" that I was using before plugging the headphones.
How can I configure the system so that it uses the headphones when they are connected, and the HDMI output when they are not? I do not want the system to use "Digital Output (S/PDIF)" at all.
According to 'user.dz' - you can trigger a script when headphones is disconnected.
when Headphone disconnects - use ACPI to trigger a script
(What code is executed when headphones are disconnected?).
Default Headphone setting within terminal for the script
Could be done with recommendation to 'Takkat's answer from
(How can I change the default audio device from command line?)
This is my first answer - I hope it helps and pardon/let me know if theres anything I should've done differently.