maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Tinkering with DBus on Jolla (https://talk.maemo.org/showthread.php?t=92303)

jukkar 2014-04-27 09:15

Re: Tinkering with DBus on Jolla
 
Quote:

Originally Posted by Schturman (Post 1422903)
I connect Jolla to BT loudspeaker and if I run:
Code:

/usr/lib/qt5/bin/qdbus --system net.connman /net/connman/technology/bluetooth net.connman.Technology.GetProperties
it show me:
Code:

Connected: false
Name: Bluetooth
Powered: true
Tethering: false
Type: bluetooth

The first line show me false although it connected and work good. :confused: Why ?

ConnMan only handles network connections so the "Connected: false" refers to BT PAN connection and as you do not have any, the value is false.

Schturman 2014-04-27 09:32

Re: Tinkering with DBus on Jolla
 
Ok, thanks for explanation.
Maybe you know how to check if BT connected to any device, when icon is white on the lockscreen ?

Ok found how to chek... I can run this command and if it connected to something it will show me the address:
Code:

[root@Jolla ~]# hcitool con|awk '{print $3}'|grep -v '^$'
00:26:7E:0A:17:84
[root@Jolla ~]#

Now if I want to see the real name of connected device:
Code:

[root@Jolla ~]# address=$(hcitool con|awk '{print $3}'|grep -v '^$')
[root@Jolla ~]# hcitool name $address
Parrot Minikit Slim v1.31
[root@Jolla ~]#

:D

geekgirl74 2014-05-29 21:56

Re: Tinkering with DBus on Jolla
 
Could I use DBUS to automagically start the mediaplayer after headset is inserted? What would be needed to achieve this? Any ideas?

szopin 2014-05-29 22:08

Re: Tinkering with DBus on Jolla
 
Quote:

Originally Posted by geekgirl74 (Post 1427317)
Could I use DBUS to automagically start the mediaplayer after headset is inserted? What would be needed to achieve this? Any ideas?

In Fremantle alsaped was pretty cool so you could scirpt it there (http://talk.maemo.org/archive/index.php/t-83447.html), would be nice to know what jolla uses

geekgirl74 2014-05-30 08:31

Re: Tinkering with DBus on Jolla
 
Sorry, I should have been more precise. I meant headphone, not headset. I can live with the fact that my headset's buttons are not supported, but I would like to automatically start the mediaplayer (maybe even start playback) when plugging in the headset/headphone.

Just started dbus-monitor to see if anything happens when music plays and I unplug the headphone. Thought this could give me a hint how to achieve the opposite, but nothing was thrown to the output when the music stopped after unplugging... now I'm out of ideas... can anybody help?

juiceme 2014-05-30 10:13

Re: Tinkering with DBus on Jolla
 
Quote:

Originally Posted by geekgirl74 (Post 1427384)
Sorry, I should have been more precise. I meant headphone, not headset. I can live with the fact that my headset's buttons are not supported, but I would like to automatically start the mediaplayer (maybe even start playback) when plugging in the headset/headphone.

Just started dbus-monitor to see if anything happens when music plays and I unplug the headphone. Thought this could give me a hint how to achieve the opposite, but nothing was thrown to the output when the music stopped after unplugging... now I'm out of ideas... can anybody help?

Try "dbus-monitor --system" as root.
I think it defaults to session bus, and the headphones seem to trigger events on system bus.

szopin 2014-05-30 11:11

Re: Tinkering with DBus on Jolla
 
Quote:

Originally Posted by geekgirl74 (Post 1427384)
Sorry, I should have been more precise. I meant headphone, not headset. I can live with the fact that my headset's buttons are not supported, but I would like to automatically start the mediaplayer (maybe even start playback) when plugging in the headset/headphone.

Just started dbus-monitor to see if anything happens when music plays and I unplug the headphone. Thought this could give me a hint how to achieve the opposite, but nothing was thrown to the output when the music stopped after unplugging... now I'm out of ideas... can anybody help?

Code:


dbus-monitor --system "type=signal, interface=com.nokia.policy, member=audio_actions" | 
while read -r line;
do
        if echo $line | grep "string \"hs\""; then
                /usr/bin/jolla-mediaplayer
        fi
done


geekgirl74 2014-05-30 11:32

Re: Tinkering with DBus on Jolla
 
Thank you. It displays a million messages, will try to find out, what it needs.

Edit: should have hit F5 prior to posting :) will try what szopin wrote.

geekgirl74 2014-05-30 12:11

Re: Tinkering with DBus on Jolla
 
Had to slightly alter the script, but it works, thanks :)

Code:

dbus-monitor --system "type=signal, interface=com.nokia.policy" | 
while read -r line;
do
        if echo $line | grep "string \"headphone\""; then
                /usr/bin/jolla-mediaplayer
        fi
done


hlub 2014-07-26 22:54

Re: Tinkering with DBus on Jolla
 
Quote:

Originally Posted by evk (Post 1421625)
Anyone now how to get GPS-coordinates through dbus? Or some other simple way that can be used from a shell script?

The following python snippet does the job (you may have to install dbus-python and/or pygobject2)

Code:

import dbus, gi.repository.GObject as gobject
import dbus.mainloop.glib as glib

glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()

def myhandler(fields, timestamp, lat, lon, alt, acc):
    print "lat: %f lon: %f alt: %d acc: %d" % (lat, lon, alt, acc[1])

bus.add_signal_receiver(myhandler,"PositionChanged",
                      "org.freedesktop.Geoclue.Position")

loop = gobject.MainLoop()
loop.run()

  • cf http://dbus.freedesktop.org/doc/dbus.../tutorial.html for everything about python-dbus
  • the script doesn't work until another GPS application (like Map) has started
  • method GetPosition fails with 'Geoclue master client has no usable Position providers', but signal PositionChanged can be used instead (as above)


All times are GMT. The time now is 02:03.

vBulletin® Version 3.8.8