I have a script that has to be run under root, with bindings to dbus.
DBUS_SESSION_BUS_ADDRESS = 'address set under .dbus file ...'
class NewApp(dbus.service.Object):
def __init__(self):
busname = dbus.service.BusName('org.newapp', dbus.SessionBus(mainloop=DBusGMainLoop()))
dbus.service.Object.__init__(self, busname, '/org/newapp')
@dbus.service.method('org.newapp', out_signature='s')
def do_stuff(self):
return 'stuff'
if __name__ == '__main__':
na = NewApp
na()
gobject.MainLoop().run()
Where do_stuff has code that needs to have root access. I have found that when you run the program under root, this creates a separate dbus session and I would need to set the 'DBUS_SESSION_BUS_ADDRESS'. I have thought about separating the script into to two different files and just import the other but, I would like to know how to do it this way too.
This is giving me trouble, I'm not sure where or how to set the address properly. If anyone has any insight I would greatly appreciate it.