code: def bus_inspector(self, bus, message):
          
  
          # We only care about stuff on this interface.  We did filter
          # for it above, but even so we still hear from ourselves
          # (hamster messages).
          if message.get_interface() != self.screensaver_uri:
              return True
  
          member = message.get_member()
  
          if member in ("SessionIdleChanged", "ActiveChanged"):
              logger.debug("%s -> %s" % (member, message.get_args_list()))
  
              idle_state = message.get_args_list()[0]
              if idle_state:
                  self.idle_from = dt.datetime.now()
  
                  # from gnome screensaver 2.24 to 2.28 they have switched
                  # configuration keys and signal types.
                  # luckily we can determine key by signal type
                  if member == "SessionIdleChanged":
                      delay_key = "/apps/gnome-screensaver/idle_delay"
                  else:
                      delay_key = "/desktop/gnome/session/idle_delay"
  
                  client = gconf.Client.get_default()
                  self.timeout_minutes = client.get_int(delay_key)
  
              else:
                  self.screen_locked = False
                  self.idle_from = None
  
              if member == "ActiveChanged":
                  # ActiveChanged comes before SessionIdleChanged signal
                  # as a workaround for pre 2.26, we will wait a second - maybe
                  # SessionIdleChanged signal kicks in
                  def dispatch_active_changed(idle_state):
                      if not self.idle_was_there:
                          self.emit('idle-changed', idle_state)
                      self.idle_was_there = False
  
                  gobject.timeout_add_seconds(1, dispatch_active_changed, idle_state)
  
              else:
                  # dispatch idle status change to interested parties
                  self.idle_was_there = True
                  self.emit('idle-changed', idle_state)
  
          elif member == "Lock":
              # in case of lock, lock signal will be sent first, followed by
              # ActiveChanged and SessionIdle signals
              logger.debug("Screen Lock Requested")
              self.screen_locked = True
  
          return
docs: Inspect the bus for screensaver messages of interest