You are not logged in.

#1 2013-10-10 12:53:07

Nareto
Member
From: Pisa,Italy
Registered: 2009-07-18
Posts: 148

How do I automate bluetooth with bluetoothctl?

It's been a while since I have used my bluetooth mouse. With bluez 4 I had a script with "hidd -search" which I ran after plugging in my bluetooth USB dongle and having set my mouse in discovery mode. Now I can do all this stuff manually in bluetoothctl, but how do I automate it? I'd like to have a script doing it or better yet a .conf file where I can put the mac address of my mouse and instruct to automatically connect to it when it sees it

sorry if it's a dumb question but I haven't found anything around

Last edited by Nareto (2013-10-10 12:54:43)

Offline

#2 2013-10-10 13:04:32

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How do I automate bluetooth with bluetoothctl?

Offline

#3 2013-10-10 13:19:22

Nareto
Member
From: Pisa,Italy
Registered: 2009-07-18
Posts: 148

Re: How do I automate bluetooth with bluetoothctl?

the first two I had seen, the last no. The last seems to interact directly with dbus... it honestly though seems too long a procedure, I'll probably just install a graphical utility to manage it for me

Offline

#4 2014-09-12 23:42:06

pierregermain
Member
From: Mty - Par - Mad - Fra
Registered: 2013-11-28
Posts: 10
Website

Re: How do I automate bluetooth with bluetoothctl?

After some hours of testing I have been able to automate the process with bluetoothctl.

You have to pass with echo (with option -e) the commands you want to execute. Every command you have to terminate it with a new line (\n). When I do connect I use the tab (\t) so that I do not need to update the script with the MAC of my keyboard.

#!/bin/bash

# enable bluetooth
sudo systemctl start bluetooth

sleep 1

# run the program bluez
echo -e 'power on\nconnect \t \nquit' | bluetoothctl

Offline

Board footer

Powered by FluxBB