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?


2 Answers 2


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.

$ pacmd list-cards | grep -B 1 bluez
    index: 10
    name: <bluez_card.00_0D_44_A6_7D_85>
        device.string = "00:0D:44:A6:7D:85"
        device.api = "bluez"
        device.form_factor = "headset"
        bluez.path = "/org/bluez/1085/hci0/dev_00_0D_44_A6_7D_85"
        bluez.class = "0x240404"
        bluez.name = "Logitech Wireless Headset"
        bluez_sink.00_0D_44_A6_7D_85/#11: Logitech Wireless Headset
        bluez_sink.00_0D_44_A6_7D_85.monitor/#22: Monitor of Logitech Wireless Headset

I've changed your script and now it's working good. (It's not maybe best solution)

This is what I changed

#SINK=$( pacmd list-cards | grep -B 1 bluez | head -1 )
INDEX=$( pacmd list-cards | grep -B 1 bluez | head -1 | awk ' { print $2 } ' )
#SINK=$( pacmd list-cards | grep bluez )
MAC=$( pacmd list-cards | grep bluez | head -1 | awk -F . ' { print substr($2,0,length($2)) }' )

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 be a2dp for audio profile, and hsp for headset telephony profile.

  • pacmd set-default-sink and pacmd 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:

# CLI options:  `a2dp': Audio Profile
#               `hsp':  Telephony Profile
#               <Index> Default Sink (try `0' or `1')

SINK=$( pacmd list-cards | grep -B 1 bluez )
SINK=$( pacmd list-cards | grep bluez )

if [ $1 = a2dp ]; then
    echo Setting A2DP audio sink $BT_SINK
    pacmd set-card-profile $INDEX a2dp
    pacmd set-default-sink $BT_SINK
elif [ $1 = hsp ]; then
    echo Setting HSP headset sink $BT_SOURCE
    pacmd set-card-profile $INDEX hsp
    pacmd set-default-sink $BT_SINK
    pacmd set-default-source $BT_SOURCE
    echo Resetting to internal audio
    pacmd set-default-sink $1
    pacmd set-default-source $1

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:

switch-sink a2dp    # switches to audio profile
switch-sink hsp     # switches to headset/telephony profile
switch-sink <index> # switches to sink <index>, e.g. 0 depending on our default

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):

    pulseaudio -k
  • Cool. In Unity I can associate such script with a right click menu and I have a right/left click solution. Thx a lot
    – stwissel
    Jul 4, 2012 at 4:19
  • Yeah, that's the advantage of CLI & scripts. You can do it all - even wrap a GUI or an AppIndicator around it. A minor issue is that we can not have more than 99 audio card indices with the primitve method here to get the card INDEX - see edit for workaround :)
    – Takkat
    Jul 4, 2012 at 6:28
  • Instead of a2dp and hsp the presets for my headphone are a2dp_sink and headset_head_unit respectivelly. You might want to add that to your answer. Nov 13, 2018 at 2:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .