Bluetooth convenience scripts

Daniel Benoy daniel at benoy.name
Fri Sep 5 22:38:06 CEST 2008


I found a useful python script on Gentoo's boards for using the bluez-utils d-bus interface for activating bluetooth keyboards so that they will connect automatically when you turn them on.  I've also modified it and created one that does the same thing for A2DP headsets, and I've decided to share :)  The keyboard one can/must be used in lieu of hidd, so it's for newer versions of bluez-utils (Available in the testing and unstable feeds)

You also have to bond (pair) the devices first.  Instructions for that are here: http://wiki.bluez.org/wiki/HOWTO/Bonding  (Feel free to make a convenience script for the bonding process too)

You may also have to run:
dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetTrusted? string:AA:BB:CC:DD:EE:FF  (Feel free to add this to the script)

If you want to use an A2DP headset you can add an entry like this to your /etc/asound.conf
----
pcm.bluetooth {
	type bluetooth
        device "AA:BB:CC:DD:EE:FF"
        profile "auto"
}
----

And then you can tell alsa aware applications to use it for output.  i.e.:

mplayer -ao alsa:device=bluetooth nifty.mp3

(I believe you can also name it pcm.!default and it will become the default.)

-- 
Daniel Benoy
http://daniel.benoy.name
-------------- next part --------------
A non-text attachment was scrubbed...
Name: audtool.py
Type: application/x-python
Size: 1067 bytes
Desc: not available
Url : http://lists.openmoko.org/pipermail/support/attachments/20080905/0cd46566/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hidtool.py
Type: application/x-python
Size: 1123 bytes
Desc: not available
Url : http://lists.openmoko.org/pipermail/support/attachments/20080905/0cd46566/attachment-0001.bin 


More information about the support mailing list