7

I have a Jabra Evolve 75 headset that I connect via Bluetooth to my Ubuntu 20.04 machine. Everything works fine in principle except for one little annoyance:

Whenever I turn the headset on, it connects and the Output Device is automatically set accordingly in the Sound Settings. This is the way I want it. However, the Input Device remains like it was set before and I manually have to go in to the settings and also change it to Jabra Evolve 75:

enter image description here

How can I configure the settings so that both Input Device and Output Device automatically switch to Jabra Evolve 75 once I turn the headset on?


UPDATE: The Input Device is also automatically switched when the Configuration setting is changed from High Fidelity Playback (A2DP Sink) to HSP/HFP. So if it is possible to automatically select that as a profile, my problem would also be solved.

buddemat
  • 487

3 Answers3

7

Ok, I finally found how to automatically switch to the HFP audio profile, which will then also automatically set the headset microphone as input device.

There are multiple approaches around, but the only way to do this automatically when connecting the bluetooth headset seems to be to create a udev rule which runs a script when the headset is connected. There is a very nice blog post that describes this in-depth which I used to achieve what I wanted and where most of the code below is originally from.

These are the essential steps:

  1. Find out card name and profile using pactl list. The output contains two lines that you will need:

    ...
    Card #20
        Name: bluez_card.70_BF_92_C9_F5_D0
        ...
     Profiles:
         a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: yes)
         handsfree_head_unit: Handsfree Head Unit (HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
         off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
    ...
    

    In this example, the card name is bluez_card.70_BF_92_C9_F5_D0 and the profile name is handsfree_head_unit.

  2. With that, create a script ~/.config/auto-pactl.sh to switch the headset to the HFP profile:

    #!/bin/bash
    sleep 2 # wait for the headset to fully connect                                 
    sudo -u '#1000' XDG_RUNTIME_DIR=/run/user/1000 \                                
        pactl set-card-profile bluez_card.70_BF_92_C9_F5_D0 handsfree_head_unit     
    logger "Switched Jabra headset to HFP profile"
    
  3. Make the script executable: chmod a+x ~/.config/auto-pactl.sh (Otherwise you will get an exit code 1 error)

  4. Find out input name of headset using udevadm monitor and then connecting the BT headset. The output should be something like:

    ...
    UDEV  [54588.946048] add      /devices/virtual/input/input112 (input)
    ...
    
  5. Find out subsytem, vendor, and product using udevadm info -ap /devices/virtual/input/input112 (replacing the device with whatever the previous command's output was)

  6. With this information, create a udev rule to execute the above script and store it in /etc/udev/rules.d/52-jabra-headset.rules, inserting the values for your card and your username in the appropriate places:

    ACTION=="add", SUBSYSTEM=="input", ATTR{id/vendor}=="0067", ATTR{id/product}=="24a7", RUN+="/home/<myUsername>/.config/auto-pactl.sh"
    

That worked like a charm for me!

buddemat
  • 487
1

UPDATE for at least 22.04

Something missing from the accepted solution... In the auto-pactl.sh script, you need to find the ID number for your current user. To do this you need to run id -u myuser and note the ID number on your user. Then use this ID in place of the "1000" in both places in the script.

Next the original sudo command structure was failing for me in 22.04. It turned out that I had to remove both the sudo line and line after and replace it with the following

sudo -u '#1000' XDG_RUNTIME_DIR=/var/run/user/1000 pactl set-card-profile bluez_card.70_BF_92_C9_F5_D0 handsfree_head_unit

I also added a couple more logger entries just to track the full script in the syslog.

#!/bin/bash
logger "Starting Bluetooth headset to HFP profile script"
logger "Starting Bluetooth headset to HFP profile script nap"
sleep 2 # wait for the headset to fully connect
logger "Bluetooth headset to HFP profile script nap complete"

sudo -u '#1001' XDG_RUNTIME_DIR=/var/run/user/1001 pactl set-card-profile bluez_card.E8_EE_CC_DB_32_74 handsfree_head_unit

logger "Switched Bluetooth headset to HFP profile"

0

I think it has to do with the "Configuration" type. You have selected A2DP, which only supports audio to the headset. Try switching to HSP/HFP, then it is bidirectional. Your sound quality may be a bit deteriorated with HSP/HFP. I haven't found any solution having high-quality audio with HSP/HFP on bluetooth.

You can also try pulseaudio volume control. It gives you more flexibility to control the sound settings.

Cheers