Linux – How to talk to geoclue through its dbus interface

arch linuxcommand lined-bus

I'm trying to better understand what geoclue does, and how to gain information from it.

From my understanding, it can be accessed through it's dbus interface to find geographic information about the user. The problem is finding the right dbus command to gain this information.

I've searched all over the internet and checked all the documentation I could find, but still can't seem to find an easy answer other than obscure information about it's dbus properties, which I lack the knowledge to properly piece together.

Is there a dbus command I could use to gain this information from geoclue, and perhaps an example of what that command should look like? I do not have the information required to put together the documentation from it to gain this.

Best Answer

Install qdbus. The syntax is:

qdbus servicename path function parameters

servicename is usually the name of a program (eg: org.freedesktop.Geoclue.Master), path is something like /org/freedesktop/Geoclue/Master/client0, function looks like org.freedesktop.Geoclue.GetStatus.

If you type an incomplete command (eg: only servicename, and not path and the rest), qdbus will reply with a list of options for the next argument. You can use this to explore the available functionality.

For example:

qdbus org.freedesktop.Geoclue.Providers.UbuntuGeoIP /org/freedesktop/Geoclue/Providers/UbuntuGeoIP org.freedesktop.Geoclue.Position.GetPosition

outputs:

3
<timestamp>
<lat>
<lon>
<alt>

Now you can use the documentation for more information.

Related Question