Connect to a Bluetooth device via Terminal
I'm using Mint 15 w/ Cinnamon.
I bought a set of bluetooth speakers and I'm trying to connect to them via terminal. Via the GUI I can see them normally and I am connected to them. I want to make a small script so every time they are visible I would connect to them automatically.
I am trying to scan them with:
But I get
and after a few seconds the process dies.
The same thing with
If I run
hciconfig scanI get:
hci0: Type: BR/EDR Bus: USB BD Address: 40:2C:F4:78:E8:69 ACL MTU: 1021:8 SCO MTU: 64:1 UP RUNNING PSCAN ISCAN RX bytes:130700 acl:22 sco:0 events:18527 errors:0 TX bytes:31875398 acl:36784 sco:0 commands:75 errors:0
I suppose that is just saying my bluetooth address and that it is turned on.
As I said already, via the normal User Interface, I can see the speakers and I am connected to them, but through terminal I get nothing.
Actually it is quite funny that
hcitool scanisn't finding anything since my speakers are connected and every time I run the command the sound from the speakers breaks for a couple of seconds.
I managed to do so via bluez-tools:
sudo apt-get install bluez-tools
List of devices to get the MAC address of my device:
and successfully connect to it:
bt-audio -c 01:02:03:04:05:06
This is probably for an old version as there is no `bt-audio` command anymore
For update follow the issue https://github.com/khvzak/bluez-tools/issues/13
On Linux Mint 17 (Cinnamon) I successfully used `bluez-test-audio connect MAC_ADDRESS` for an already paired audio device.
On Ubuntu 18.04, bt-audio is not available. Judging from bluez-audio issue #13, this has been the case for years. Running `bt-device -c ` doesn't help ("Error: GDBus.Error:org.bluez.Error.AlreadyExists: Already Exists") and I'm reluctant to go into hacks suggested under issue #13 because I have to do them on each machine, I expect they'll be deprecated easily etc. Can it really be that (after navigating to the right part of the settings GUI) it's a single click on GUI to redirect sound to a speaker, but that there's still no way to do it in a single, simple command from the CLI?