Skip to content

Instantly share code, notes, and snippets.

@jonls
Created May 9, 2014 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonls/11337107e84442dd783d to your computer and use it in GitHub Desktop.
Save jonls/11337107e84442dd783d to your computer and use it in GitHub Desktop.
Geoclue2 test
#!/usr/bin/env python
import dbus
if __name__ == '__main__':
bus = dbus.SystemBus()
manager_obj = bus.get_object('org.freedesktop.GeoClue2', '/org/freedesktop/GeoClue2/Manager')
manager = dbus.Interface(manager_obj, 'org.freedesktop.GeoClue2.Manager')
client_path = manager.GetClient()
print 'Client at {}'.format(client_path)
client_obj = bus.get_object('org.freedesktop.GeoClue2', client_path)
client = dbus.Interface(client_obj, 'org.freedesktop.GeoClue2.Client')
client_props = dbus.Interface(client_obj, 'org.freedesktop.DBus.Properties')
client_props.Set('org.freedesktop.GeoClue2.Client', 'DistanceThreshold', dbus.UInt32(10000))
client.Start()
print 'Client started...'
location_path = client_props.Get('org.freedesktop.GeoClue2.Client', 'Location')
location_obj = bus.get_object('org.freedesktop.GeoClue2', location_path)
location_props = dbus.Interface(location_obj, 'org.freedesktop.DBus.Properties')
print 'Location at {}'.format(location_path)
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Latitude')
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Longitude')
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Accuracy')
print location_props.Get('org.freedesktop.GeoClue2.Location', 'Description')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment