Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import dbus
- from dbus.mainloop.glib import DBusGMainLoop
- def location_updated(old_path, new_path):
- print "Old location path = " + str(old_path)
- print "New location path = " + str(new_path)
- def main():
- dbus_loop = DBusGMainLoop(set_as_default = True)
- system_bus = dbus.SystemBus(mainloop = dbus_loop)
- manager_object = system_bus.get_object('org.freedesktop.GeoClue2', '/org/freedesktop/GeoClue2/Manager')
- manager = dbus.Interface(manager_object, 'org.freedesktop.GeoClue2.Manager')
- client_path = manager.GetClient()
- client_object = system_bus.get_object('org.freedesktop.GeoClue2', client_path)
- client = dbus.Interface(client_object, 'org.freedesktop.GeoClue2.Client')
- client.connect_to_signal('LocationUpdated', location_updated)
- client.Start()
- properties = dbus.Interface(client_object, 'org.freedesktop.DBus.Properties')
- location_path = properties.Get('org.freedesktop.GeoClue2.Client', 'Location')
- print "Path to Location Object = " + str(location_path) # Always prints '/' irrespective of client.Start()
- client.Stop()
- main()
Advertisement
Add Comment
Please, Sign In to add comment