Connect to bluetooth device from command line

Posted by Ilari Kajaste on Ask Ubuntu See other posts from Ask Ubuntu or by Ilari Kajaste
Published on 2011-06-10T08:23:18Z Indexed on 2012/06/11 10:48 UTC
Read the original article Hit count: 261

Filed under:
|

Background: I'm using my bluetooth headset as audio output. I managed to get it working by the long list of instructions on BluetoothHeadset community documentation, and I have automated the process of activating the headset as default audio output into a script, thanks to another question.

However, since I use the bluetooth headset with both my phone and computer (and the headset doesn't support two input connections) in order for the phone not to "steal" the connection when handset is turned on, I force the headset into a discovery mode when connecting to the computer (phone gets to connect to it automatically).

So even though the headset is paired ok and would in "normal" scenario autoconnect, I have to always use the little bluetooth icon in the notification area to actually connect to my device (see screenshot).

What I want to avoid: This GUI for connecting to a known and paired bluetooth device:

Connecting to Bluetooth headset using icon

What I want instead: I'd want to make the bluetooth do exactly what the clicking the connect item in the GUI does, only by using command line. I want to use command line so I can make a single keypress shortcut for the action, and would't need to navigate the GUI every time I want to establish a connection to the device.

The question: How can I attempt to connect to a specific, known and paired bluetooth device from command line?

Further question: How do I tell if the connection was successful or not?

© Ask Ubuntu or respective owner

Related posts about command-line

Related posts about bluetooth