My Computer is My Bluetooth Headset

I know! Not everyone would like to use a headset connected to their laptop instead of their phone's speaker and its own mic! But since I mostly live on the desktop, I'd like to answer my calls on my laptop itself, just for a fun weekend poking.

Bluetooth Headset

So one option is to have your headset paired to a bluetooth headset, and use that instead of the my phone. But for that, I need to buy a new bluetooth headset. But I really dont need to! Thats the beautiful thing with standards.

Bluetooth HFP

Enter the bluetooth Hands-Free Profile. This is the same bluetooth standard which is the reason why your dedicated bluetooth headset just works. You probably guessed it - we just need an implementation of the Bluetooth HFP profile on my laptop to use it as a handsfree.

Bluez is what you're looking for. That is the defacto bluetooth stack for Linux. But there is a small complication here. Bluez 4 had support for HFP, but with Bluez 5, the support was removed, owing to some redesign, and the work isnt completed. So, we need some workarounds. The solution, is to use something called Ofono with Bluez 5.

Setup

I am on ArchLinux, and I would provide instructions for the same.
First, install the necessary packages available in the repos for supporting Pulseaudio with Bluetooth.

Pulseaudio is the defacto sound server that runs on most of the Linux desktops. You need to integrate bluetooth with it, so as to get things to work perfectly.

sudo pacman -S pulseaudio-bluetooth blueman  

Blueman provides a nice GUI base config utility to change your phone's Audio profile being used.

HFP Support

Now its time to bring in Ofono. Its little bit overkill to use Ofono, but well, we are out of options.

Ofono is available in AUR, but the PKGFILE needs some changes. You may download the AUR snapshot and replace it with my version and follow the procedure below:

First of all, install the gpg keys for downloaded keys and trust it:

gpg2 --recv-keys 0x06CA9F5D1DCF2659  

Please follow the instruction in GnuPG to know how to trust a key. If you prefer a GUI to do it, one option, is to install and configure a Thunderbird extension called Enigmail. It provides a GUI interface to manage your GPG Keys. Another lightweight option would be Seahorse, which is available in the repos.

Now get the modified version of Ofono from https://gist.github.com/aurabindo/167b881f0f3c8ed6bd02d85fffa1e20c and put it into a new folder (just for convenience) and run makepkg. Now your package would be generated. Simply install the pacakge and enable the Ofono service:

sudo pacman -U ofono-1.19-1-x86_64.pkg.tar.xz  
sudo systemctl enable ofono  
sudo systemctl start ofono  

Now open the default pulseaudio configuration file and locate the lines:

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover  
.endif

Now replace it with:

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover headset=ofono  
.endif

Now we're ready to restart pulseaudio

pulseaudio -k  
pulseaudio --start  

Now from your phone, pair your laptop as usual, and open Blueman.

Right-Click on the entry for your phone, in the Audio profile section, and select HFP:

Blueman Screenshot

Enjoy!

Further Thoughts

One shortcoming would be that I still need to have the phone in my vicinity so as to attend a call when I get one. A perfect solution would be to have the phone notify me somehow about the call, and I accept the call right from the desktop itself, without reaching for the phone!