xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #492: dbus-suspendresume-notifications.patch

File dbus-suspendresume-notifications.patch, 2.2 KB (added by Antoine Martin, 7 years ago)

dbus hooks for trying to get suspend/resume notifications

  • xpra/platform/xposix/gui.py

     
    6565        self._root_props_watcher = None
    6666        if client.xsettings_enabled:
    6767            self.setup_xprops()
     68        self.setup_dbus_signals()
    6869
    6970    def cleanup(self):
    7071        log("cleanup() xsettings_watcher=%s, root_props_watcher=%s", self._xsettings_watcher, self._root_props_watcher)
     
    7576            self._root_props_watcher.cleanup()
    7677            self._root_props_watcher = None
    7778
     79
     80    def setup_dbus_signals(self):
     81        try:
     82            from xpra.x11.dbus_common import init_system_bus
     83            bus = init_system_bus()
     84            upower_object = bus.get_object("org.freedesktop.UPower", "/org/freedesktop/UPower")
     85            def resuming_callback(*args):
     86                log.info("resuming(%s)", args)
     87                print("resuming!")
     88            def sleeping_callback(*args):
     89                log.info("sleeping(%s)", args)
     90                print("sleeping!")
     91            bus.add_signal_receiver(resuming_callback, 'Resuming', 'org.freedesktop.UPower', 'org.freedesktop.UPower')
     92            bus.add_signal_receiver(sleeping_callback, 'Sleeping', 'org.freedesktop.UPower', 'org.freedesktop.UPower')
     93            #upower_object.connect_to_signal("Resuming", resuming)
     94            log.info("waiting for 'Resuming' and 'Sleeping' signals on %s", upower_object)
     95        except Exception, e:
     96            log.warn("dbus setup error: %s", e)
     97       
    7898    def setup_xprops(self):
    7999        #wait for handshake to complete:
    80100        self.client.connect("handshake-complete", self.do_setup_xprops)
  • xpra/x11/dbus_common.py

     
    2121    import dbus
    2222    _session_bus = dbus.SessionBus()
    2323    return _session_bus
     24
     25_system_bus = None
     26def init_system_bus():
     27    global _system_bus
     28    if _system_bus:
     29        return _system_bus
     30    loop_init()
     31    import dbus
     32    _system_bus = dbus.SystemBus()
     33    return _system_bus