[ create a new paste ] login | about

Link: http://codepad.org/dauMCxXY    [ raw code | fork ]

Python, pasted on Feb 23:
    def run(self):
        
        # Monitor DBUS    
        DBusGMainLoop(set_as_default=True)
        
        bus = dbus.SessionBus()
        
        # We only want notifications, filter the rest out
        bus.add_match_string_non_blocking('interface=org.freedesktop.Notifications')
        
        # Send the notifications/events to our handler
        bus.add_message_filter(self.handler)
        
        loop = gobject.MainLoop()
        loop.run()
                
    def handler(self, *args):
                
        if args[1].get_interface() == "org.freedesktop.Notifications" and args[1].get_member() == "Notify":
    
            method_args = args[1].get_args_list()
            
            if len(method_args[3].strip()):
                
                application = method_args[0]
                event = "%s" % method_args[3]
                description = "%s" % strip_tags(method_args[4])
                priority = 0 # Set to normal by default
                
                if method_args[6].get('urgency', 1) == 0:  
                    priority = -1 # Low
                elif method_args[6].get('urgency', 1) == 1:
                    priority = 0 # normal
                elif method_args[6].get('urgency', 1) == 2:
                    priority = 2 # critical
                
                pusher_process = Process(target=self.pusher, args=(application, event, description, '', priority, False))
                pusher_process.start()


Create a new paste based on this one


Comments: