public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: Alexander H Deriziotis <deriziotis@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: Connecting to Bluetooth Speakers via command line
Date: Thu, 19 Nov 2009 14:35:35 +0200	[thread overview]
Message-ID: <20091119123535.GA4305@jh-x301> (raw)
In-Reply-To: <5eee8c670911190321gd44f7f4x522dc8af67e19c2f@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]

Hi Alex,

On Thu, Nov 19, 2009, Alexander H Deriziotis wrote:
> In Ubuntu 9.10 the Bluetooth applet has improved functionality for
> managing connected devices. Once I pair my Bluetooth speakers with my
> computer, I can click on the Bluetooth applet, select my speakers and
> click ‘Connect’ in order to establish a connection.
> 
> This seems to automatically connect to the speakers and create a
> pulseaudio sink for me which I can use, however, every time I reboot,
> I need to manually click on Connect again to get my sink back.
> 
> Is there any way to connect to my Bluetooth speakers from the
> command-line, so that I can set-up my system to automatically use the
> relevant sink whenever I boot-up?

I think the Bluetooth applet is using the org.bluez.Audio.Connect D-Bus
method to create the connection. You can call it from the command line
using e.g. the attached python script (I also realized this was missing
from the bluez source tree so it's now added there too). I also think
that it could be a nice feature if in the Bluetooth applet you could
mark devices to be auto-connected when the applet starts.

Johan

[-- Attachment #2: test-audio --]
[-- Type: text/plain, Size: 647 bytes --]

#!/usr/bin/python

import sys
import dbus

bus = dbus.SystemBus()

manager = dbus.Interface(bus.get_object("org.bluez", "/"), "org.bluez.Manager")
adapter = dbus.Interface(bus.get_object("org.bluez", manager.DefaultAdapter()),
				"org.bluez.Adapter")

if len(sys.argv) < 3:
	print """Usage: %s <command>

	connect <bdaddr>
	disconnect <bdaddr>
	""" % sys.argv[0]
	sys.exit(1)

device = adapter.FindDevice(sys.argv[2])
audio = dbus.Interface(bus.get_object("org.bluez", device),
				"org.bluez.Audio")

if sys.argv[1] == "connect":
	audio.Connect()
elif sys.argv[1] == "disconnect":
	audio.Disconnect()
else:
	print "Unknown command"
	sys.exit(1)

  reply	other threads:[~2009-11-19 12:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-19 11:21 Connecting to Bluetooth Speakers via command line Alexander H Deriziotis
2009-11-19 12:35 ` Johan Hedberg [this message]
2009-11-19 12:50   ` Bastien Nocera
2009-11-19 13:13     ` Johan Hedberg
2009-11-19 14:13     ` Alexander H Deriziotis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091119123535.GA4305@jh-x301 \
    --to=johan.hedberg@gmail.com \
    --cc=deriziotis@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox