2009-11-19 11:21:53

by Alexander H Deriziotis

[permalink] [raw]
Subject: Connecting to Bluetooth Speakers via command line

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


2009-11-19 14:13:20

by Alexander H Deriziotis

[permalink] [raw]
Subject: Re: Connecting to Bluetooth Speakers via command line

2009/11/19 Bastien Nocera <[email protected]>:
> 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 :)

2009-11-19 13:13:50

by Johan Hedberg

[permalink] [raw]
Subject: Re: Connecting to Bluetooth Speakers via command line

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

2009-11-19 12:50:27

by Bastien Nocera

[permalink] [raw]
Subject: Re: Connecting to Bluetooth Speakers via command line

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


2009-11-19 12:35:35

by Johan Hedberg

[permalink] [raw]
Subject: Re: Connecting to Bluetooth Speakers via command line

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


Attachments:
(No filename) (1.11 kB)
test-audio (647.00 B)
Download all attachments