The way I understand it, with USB audio, every headphone and speaker essentially registers as its own sound card so there is no difference any more between “headphone” and “speakers”, they are all just “sound cards” as far as the operating system is concerned which obviously presents challenges in automatically managing the common idea that speakers should automatically disable when headphones are plugged in.
Right now, I have a simple daemon written in Bash that simply monitors for USB devices being connected and is simply hardcoded to detect my headphones. Alongside that I have two different speakers as well in my machine so the daemon operates in a simple way: if the headphones be plugged in, then it pipes a loopback device to the headphones, else it pipes it to both speaker sound cards. The names it detects them by are hardcoded into the script so this works for my own use case but this cannot be a proper general solution. I use pure ALSA and no Pipewire or anything like that so I don't know what that does but do USB headphones have some kind of way to “report” that they're headphones and should take priority over speakers? Does Pipewire simply give priority to the last USB sound card inserted? then if so, how would it manage the situation that if the headphones not be inserted it needs to route audio to both fixed speakers? Is the user meant to simply hardcode this in some way based on identifier strings which doesn't feel right to me.

