Using a bluetooth headset that does Stereo (out only), mono (in / out) and speakers. Switching between the 3 is a lot of clicks. What I want to do: - run Stereo either on Speaker or headset - when I make or accept a voip call (Skype, gTalk etc): switch to thr Bluetooth profile with input enabled - switch back after the call
.or. Have a simple menu (indicator?) that allows me to switch between preset combinations of in/out
How do I do that?
I think I found a bug with this solution. In my case only 1 was set as index so I've got this error >>> No card found by this name or index.
I've changed your script and now it's working good. (It's not maybe best solution)
This is what I changed
To my knowledge there is not a simple one-click solution that would give us a fast switching from internal audio to Bluetooth A2DP audio profile, and Bluetooth HSP headset profile.
However we can change the sound output from command line that gives us the opportunity to create a script to switch the audio output. The commands we need are the following:
pacmd list-cards
will list the cards available. As soon as a headset is connected we will have access to the Bluetooth audio properties. In addition we can now find out the pulseaudio card index, and possible profiles for the following commands.
pacmd set-card-profile <index> <profile>
changes the profile for a card number
<index>
. For a Bluetooth card the profile in question will bea2dp
for audio profile, andhsp
for headset telephony profile.pacmd set-default-sink
andpacmd set-default-source
will change the output resp. input used by pulseaudio. This can not be done during playback. See this answer for details on how to do that.
Below there is an example script that may be used to switch the sound output for a Bluetooth headset:
Copy the script, save it as
switch-sink
, and grant it executable permission. In a terminal change to the script directory and issue the script with the following options:Give the full path to the script when executing from a keyboard shortcut or from a .desktop file (for desktop or launcher).
Additional note on sound card INDEX:
In case there are more than 99 sound cards registered with pulseaudio this script here will not work. This may become an issue as the card INDEX will be increased with every power ON or reconnect of a Bluetooth device. As a workaround we may change the last
else
condition to reset the pulseaudio server (which will then also load our default audio sink):