Pipewire can switch to headset mode automatically whenever a microphone input is needed. And it switches it back to headphone mode afterwards.
It works on Linux exactly like on a phone or macOS.
Pipewire is backwards compatible with Pulseaudio so there is no reason to not migrate.
I've not heard of pipewire. Need to check this out because I'd love for my truly wireless earphones to be able to seamlessly switch modes on Ubuntu. I use a wired headset for work calls I need to be on quickly because it's pretty flawless, but the tether is more than a little annoying.
EDIT: It took me 5 minutes after reading the comment above to replace pulseaudio with pipewire on Ubuntu 20.04, now I have access to my earphones' high quality codecs too right from the Ubuntu sound control panel!
EDIT2: Switching to/from my earphones and from 1 bud to 2 buds appears flawless so far, even for the Spotify desktop for Linux app which usually requires a `pulseaudio -k` to send the audio out of the right device usually, even if it's correctly selected in sound settings.
EDIT3: Don't forget to mask pulseaudio (yellow box, second link) or pulseaudio will load on reboot and break things, no amount of systemctl disable will stop it without masking.
EDIT4: Linked site has different theme on mobile so yellow box in EDIT3 isn't yellow.
oooh... Thanks! Thanks!... This was a breeze and I had to pinch myself to make sure that it was really working...
PS: In the past, I've wrestled with PulseAudio & BT dongles and my JBL headsets on Ubuntu. Banging my head on a brick wall would have been more pleasurable than that.
PPS: and today we have Pipewire on the front page!
Glad you got it working. I deserve no credit though, I just followed some instructions and linked it here.
It was even easier to setup on my desktop (now running Manjaro rather than Ubuntu because of SteamPlay/Proton et al) and simply `sudo pacman -Sy manjaro-pipewire` followed by a reboot. If it complains about pulseaudio related conflicts, just `pacman -R` the packages it mentions then try manjaro-pipewire again, and then reboot and you're done.
I sort of had heard of pipewire - but only to the extent that it was the next audio/video stack.. No idea about how far along it was. Also no idea that it had the BT headset thingy all sorted out.
Your comment made me go "huh! that's easy enough to finish off in 10 now" and provided the impetus I needed