public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* Connecting to Bluetooth Speakers via command line
@ 2009-11-19 11:21 Alexander H Deriziotis
  2009-11-19 12:35 ` Johan Hedberg
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander H Deriziotis @ 2009-11-19 11:21 UTC (permalink / raw)
  To: linux-bluetooth

Forgive me if this isn't the correct place to ask this.

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?

Many thanks,

Alex

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Connecting to Bluetooth Speakers via command line
  2009-11-19 11:21 Connecting to Bluetooth Speakers via command line Alexander H Deriziotis
@ 2009-11-19 12:35 ` Johan Hedberg
  2009-11-19 12:50   ` Bastien Nocera
  0 siblings, 1 reply; 5+ messages in thread
From: Johan Hedberg @ 2009-11-19 12:35 UTC (permalink / raw)
  To: Alexander H Deriziotis; +Cc: linux-bluetooth

[-- 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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Connecting to Bluetooth Speakers via command line
  2009-11-19 12:35 ` Johan Hedberg
@ 2009-11-19 12:50   ` Bastien Nocera
  2009-11-19 13:13     ` Johan Hedberg
  2009-11-19 14:13     ` Alexander H Deriziotis
  0 siblings, 2 replies; 5+ messages in thread
From: Bastien Nocera @ 2009-11-19 12:50 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: Alexander H Deriziotis, linux-bluetooth

On Thu, 2009-11-19 at 14:35 +0200, Johan Hedberg wrote:
> 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.

We could probably have it try to connect to all the known audio devices
on startup, but that'd probably break some things when multiple devices
can be used.

How about trying to connect to the last used audio device? That would
probably solve most use cases, and avoid surprises.

Do you want to file a bug against gnome-bluetooth to ask for that? I'll
try to implement it then.

Cheers


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Connecting to Bluetooth Speakers via command line
  2009-11-19 12:50   ` Bastien Nocera
@ 2009-11-19 13:13     ` Johan Hedberg
  2009-11-19 14:13     ` Alexander H Deriziotis
  1 sibling, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2009-11-19 13:13 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: Alexander H Deriziotis, linux-bluetooth

Hi Bastien,

On Thu, Nov 19, 2009, Bastien Nocera wrote:
> > 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.
> 
> We could probably have it try to connect to all the known audio devices
> on startup, but that'd probably break some things when multiple devices
> can be used.

Yes, and it'd also be quite bad if a user has lots of paired devices.
Each connect attempt to a device that's not connectable or within range
would block the Bluetooth adapter for the page timeout duration which is
typically between 5 and 20 seconds.

> How about trying to connect to the last used audio device? That would
> probably solve most use cases, and avoid surprises.

Yeah, that sounds like a better option to me. Maybe it would also make
sense to make this configurable since I have a feeling that not all
people will want to have their PC exhibiting this kind of behavior upon
bootup.

> Do you want to file a bug against gnome-bluetooth to ask for that? I'll
> try to implement it then.

Since I personally don't have a strong need for this feature I think
it'd be good if Alexander who originally brought up the issue would do
it so he can also do the fix verification later on.

Johan

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Connecting to Bluetooth Speakers via command line
  2009-11-19 12:50   ` Bastien Nocera
  2009-11-19 13:13     ` Johan Hedberg
@ 2009-11-19 14:13     ` Alexander H Deriziotis
  1 sibling, 0 replies; 5+ messages in thread
From: Alexander H Deriziotis @ 2009-11-19 14:13 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: Johan Hedberg, linux-bluetooth

2009/11/19 Bastien Nocera <hadess@hadess.net>:
> On Thu, 2009-11-19 at 14:35 +0200, Johan Hedberg wrote:
>
> How about trying to connect to the last used audio device? That would
> probably solve most use cases, and avoid surprises.
>
> Do you want to file a bug against gnome-bluetooth to ask for that? I'll
> try to implement it then.
>
> Cheers
>

Hi Bastien,

This would fit my needs perfectly. If I want to stop using the
bluetooth speakers, I'll just Disconnect them through the applet.
Sounds pretty intuitive.

Hopefully I've filed the bug in the correct place:

https://bugzilla.gnome.org/show_bug.cgi?id=602409

I take it if anyone disagrees with this behaviour, then they'll raise
it here, or on the bugreport.

Thanks,
Alex

p.s. Thanks Johan for the script, I'll test it when I get home tonight :)

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-19 14:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-19 11:21 Connecting to Bluetooth Speakers via command line Alexander H Deriziotis
2009-11-19 12:35 ` Johan Hedberg
2009-11-19 12:50   ` Bastien Nocera
2009-11-19 13:13     ` Johan Hedberg
2009-11-19 14:13     ` Alexander H Deriziotis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox