Crazy Bluetooth issues on Linux with Bose QC35 headphones

Yet another update for Ubuntu 17.04

I continued to struggle with bluetooth issues when I'd reboot or put the laptop to sleep. I would have to restart the bluetooth service every time. When I'd reboot, I'd have to remove the headphones as a device and add them back every time. It was quite a problem. I finally found an article that talks about this issue and addresses it. Particularly the section under Troubleshooting titled Refused to switch profile to a2dp_sink: Not connected. For prosperity, I will put that section below:

Refused to switch profile to a2dp_sink: Not connected

Bluetooth headset is connected, but ALSA/PulseAudio fails to pick up the connected device or there's no device to pick. This happens because GDM captures A2DP sink on session start, as GDM needs pulseaudio in the gdm session for accessibility. For example, the screen reader requires it. See 805414 for some discussion.

Workaround 1: disable pulseaudio in gdm

In order to prevent GDM from capturing the A2DP sink on session start, edit /var/lib/gdm3/.config/pulse/client.conf (or create it, if it doesn't exist):

autospawn = no
daemon-binary = /bin/true

After that you have to grant access to this file to gdm user:

chown gdm:gdm /var/lib/gdm3/.config/pulse/client.conf

You will also need to disable pulseaudio startup:

rm /var/lib/gdm3/.config/systemd/user/sockets.target.wants/pulseaudio.socket In order to auto-connect a2dp for some devices, add this to /etc/pulse/default.pa:

load-module module-switch-on-connect

Reboot.

Update again for Ubuntu 17.04

I was having connectivity issues again after rebooting my laptop. I had to change Enable=Socket back to Disable=Socket. Furthermore, I had to use Blueman to "Trust" the headphones to allow reconnection without setting the headphones up everytime I turned them off and back on. However, I will leave the update below in place, just in case. As it seems to help me overcome my issues initially.

Update for Ubuntu 17.04

Once I upgraded to Ubuntu 17.04, I had to play around with Bluetooth again. Follow the steps below, but there is one line in the /etc/bluetooth/main.conf file you need to change. Instead of Disable=Socket change that to Enable=Socket. After this, restart bluetooth, connect your headset and run pacmd set-card-profile <index> a2dp_sink. Where <index> is the number of your index from the command pacmd list-cards.

Bluetooth on Ubuntu Linux

For a while, I simply could not get my Bose QC35 headphones to connect to my Thinkpad while running Ubuntu Linux. I had the hack some crap to get them working. I'm not quite sure why Bluetooth is still a pain in the ass on Linux, but it is by far the worst experience ever for me. I thought Apple was bad with handling Bluetooth, but Linux wanted to prove me wrong.

I actually have forgotten most of what I did, as it was over weeks of working on it that I finally got the stuff working properly. So, I will post here what I have changed and edit this post as I remember crap. I'm sure I'll need to remember how I did this in the future as well.

Change the bluetooth config files

Get on over to /etc/bluetooth and edit main.conf. The sections I added under the [General] section are as follows:

ControllerMode = bredr
AutoEnable=true    
Disable=Socket    
Enable=Gateway,Source    
Master=true    
AutoConnect=true    

[Headset]    
HFP=true    
MaxConnected=2 

Once you do that, run systemctl restart bluetooth or just reboot your system completely if you're so inclined. Once that's done, you should be able to pair your bluetooth headset with a tool of your choice. Try blueman or the Gnome bluetooth setup tool. Make absolutely sure when you pair that the headphones have the profile of A2DP Sink or they won't work correctly.

Your headphones should pair when you turn them on from here on out and work with audio properly. I remember, at some point, I had to disable loading module-bluetooth-discover at bootup and load it after everything else was loaded by running pactl load-module module-bluetooth-discover. I just added it to my init section in my i3 config file. However, as of the latest from Ubuntu 16.10, that doesn't appear to be a necessity anymore. In 16.04.1, it was.

Notes

  • If you're having issues where your headphones say "Connecting to..." over and over and then give up, turn them off and back on again and it should connect the second time. I have this issue sometimes after I reboot my computer.
  • There may be other things I did, but I'm forgetting. If you're having issues, leave a note and I'll track down some more things, or update this post when I remember.