def getNotification(): global nt pynotify.uninit() pynotify.init("volumecontroller") nt = pynotify.Notification(" ") nt.set_hint_int32("value",50) nt.set_hint_string("x-canonical-private-synchronous","")
def deactivate(self, shell): self.remove_ui() pynotify.uninit() del self.boxui del self.config_dialog del self.settings
def __init__(self): pynotify.uninit() pynotify.init("sun") self.pkg_count = fetch()[0] self.message_added = "" self.summary = "{0}Software Updates".format(" " * 14) self.message = ("{0}{1} Software updates are available\n".format( " " * 3, self.pkg_count)) self.icon = "{0}{1}.png".format(icon_path, __all__) self.n = pynotify.Notification(self.summary, self.message, self.icon) self.n.set_timeout(60000 * int(config()["STANDBY"]))
def main(): # make the parameters saved in enviromental variables easier accessible try: event_type = os.environ['EVENT_TYPE'] # this script can handle only the msg type if event_type != 'msg': sys.exit(1) #event_network = os.environ['EVENT_NETWORK'] #event_local_user = os.environ['EVENT_LOCAL_USER'] event_remote_user = os.environ['EVENT_REMOTE_USER'] event_message = os.environ['EVENT_MESSAGE'] #event_message_html = os.environ['EVENT_MESSAGE_HTML'] except KeyError: # some necessary parameters are missing sys.exit(1) if not pynotify.init('Extaction-plugin handler'): sys.exit(1) title = 'Message from %s:' % event_remote_user # event_message is in UTF-8, decode it to Unicode, then select first 256 # characters and encode them back to UTF-8 body = event_message.decode('utf-8')[0:256].encode('utf-8') # and escape the '&', '<', '>' characters body = cgi.escape(body) n = pynotify.Notification(title, body) if os.environ.has_key('EVENT_REMOTE_USER_ICON'): # the icon is encoded in base64, decode it first icon_encoded = os.environ['EVENT_REMOTE_USER_ICON'] icon_decoded = base64.b64decode(icon_encoded) # create a pixbuf loader loader = pynotify.gtk.gdk.PixbufLoader() loader.set_size(48, 48) loader.write(icon_decoded) loader.close() # set icon from the pixbuf pixbuf = loader.get_pixbuf() n.set_icon_from_pixbuf(pixbuf) # get the notification on the screen n.show() pynotify.uninit()
def main(): # make the parameters saved in enviromental variables easier accessible try: event_type = os.environ['EVENT_TYPE'] # this script can handle only the msg type if event_type != 'msg': sys.exit(1) #event_network = os.environ['EVENT_NETWORK'] #event_local_user = os.environ['EVENT_LOCAL_USER'] event_remote_user = os.environ['EVENT_REMOTE_USER'] event_message = os.environ['EVENT_MESSAGE'] #event_message_html = os.environ['EVENT_MESSAGE_HTML'] except KeyError: # some necessary parameters are missing sys.exit(1) if not pynotify.init('Extaction-plugin handler'): sys.exit(1) title = 'Message from %s:' % event_remote_user # event_message is in UTF-8, decode it to Unicode, then select first 256 # characters and encode them back to UTF-8 body = event_message.decode('utf-8')[0:256].encode('utf-8') # and escape the '&', '<', '>' characters body = cgi.escape(body) n = pynotify.Notification(title, body) if os.environ.has_key('EVENT_REMOTE_USER_ICON'): # the icon is encoded in base64, decode it first icon_encoded = os.environ['EVENT_REMOTE_USER_ICON'] icon_decoded = base64.b64decode(icon_encoded) # create a pixbuf loader loader = pynotify.gtk.gdk.PixbufLoader(); loader.set_size(48, 48); loader.write(icon_decoded); loader.close() # set icon from the pixbuf pixbuf = loader.get_pixbuf() n.set_icon_from_pixbuf(pixbuf) # get the notification on the screen n.show() pynotify.uninit()
def parse_js_obj(self,message_data): self.decoded = json.loads(message_data) print 'DECODED:', self.decoded print self.decoded[0]['data']['message'] fob = open('dwrite' ,'w') for item in self.decoded: fob.write("%s\n" % item) fob.close() pynotify.init ("Hello world") Hello=pynotify.Notification ("Message Received!","You have an unread message..","dialog-information") Hello.show () pynotify.uninit () msg_read.main()
def plugin_init(self): # Initialize pynotify pynotify.init('fbnotify') # Wait for context while not self.context: pass # Main loop self.running = True while self.running: # Call PluginContext.receive to get messages self.context.receive() time.sleep(1) # Done pynotify.uninit()
def show_notice(message, retry=True, notice=notice): try: if not pynotify.is_initted(): pynotify.init(sys.argv[0]) if not notice: notice = pynotify.Notification(title, message) else: notice.update(title, message) notice.show() except GError: # libnotify's documentation is… awful. This song and dance is required # because at some point in the process lifecycle pynotify loses its # connection and raises. Disconnecting and reestablishing the # connection gets things back on track. notice = None pynotify.uninit() if retry: show_notice(message, False)
def notifier_close(): if sys.platform == 'linux2': import pynotify pynotify.uninit()
def on_unload(self): pynotify.uninit()
def __del__(self): pynotify.uninit()
def run(self): logger.info('[GnomeTakeSnapshotCallback.run]') gtk.gdk.threads_init() display = gtk.gdk.display_get_default() if display is None: logger.info('[GnomeTakeSnapshotCallback.run] display KO') return status_icon = None try: status_icon = gtk.StatusIcon() except: pass if status_icon is None: logger.info('[GnomeTakeSnapshotCallback.run] no status_icon') return attach_notification = True last_message = None first_error = self.cfg.is_notify_enabled() status_icon.set_from_stock(gtk.STOCK_SAVE) status_icon.set_visible(True) pynotify.init(self.cfg.APP_NAME) self.notification = pynotify.Notification(self.cfg.APP_NAME, '', '') self.notification.set_urgency(pynotify.URGENCY_NORMAL) self.notification.set_timeout(pynotify.EXPIRES_NEVER) status_icon.connect('activate', self.show_notification) logger.info('[GnomeTakeSnapshotCallback.run] begin loop') while True: gtk.main_iteration(False) if self.stop_flag: break if not gtk.events_pending(): if attach_notification: attach_notification = False self.notification.attach_to_status_icon(status_icon) message = self.snapshots.get_take_snapshot_message() if message is None and last_message is None: message = (0, _('Working...')) if not message is None: if message != last_message: last_message = message urgency = pynotify.URGENCY_NORMAL icon_name = gtk.STOCK_SAVE status_icon_blinking = False if last_message[0] != 0: urgency = pynotify.URGENCY_CRITICAL icon_name = 'dialog-error' status_icon_blinking = True status_icon.set_blinking(status_icon_blinking) status_icon.set_tooltip(last_message[1]) self.notification.update(self.cfg.APP_NAME, last_message[1], icon_name) self.notification.set_urgency(urgency) if last_message[0] != 0 and first_error: first_error = False self.notification.set_timeout(10000) self.notification.show() time.sleep(0.2) status_icon.set_visible(False) gtk.main_iteration(False) self.notification.close() pynotify.uninit() logger.info('[GnomeTakeSnapshotCallback.run] end loop')
def run(self): logger.info( '[GnomeTakeSnapshotCallback.run]' ) gtk.gdk.threads_init() display = gtk.gdk.display_get_default() if display is None: logger.info( '[GnomeTakeSnapshotCallback.run] display KO' ) return status_icon = None try: status_icon = gtk.StatusIcon() except: pass if status_icon is None: logger.info( '[GnomeTakeSnapshotCallback.run] no status_icon' ) return attach_notification = True last_message = None first_error = self.cfg.is_notify_enabled() status_icon.set_from_stock( gtk.STOCK_SAVE ) status_icon.set_visible( True ) pynotify.init( self.cfg.APP_NAME ) self.notification = pynotify.Notification( self.cfg.APP_NAME, '', '' ) self.notification.set_urgency( pynotify.URGENCY_NORMAL ) self.notification.set_timeout( pynotify.EXPIRES_NEVER ) status_icon.connect('activate', self.show_notification ) logger.info( '[GnomeTakeSnapshotCallback.run] begin loop' ) while True: gtk.main_iteration( False ) if self.stop_flag: break if not gtk.events_pending(): if attach_notification: attach_notification = False self.notification.attach_to_status_icon( status_icon ) message = self.snapshots.get_take_snapshot_message() if message is None and last_message is None: message = ( 0, _('Working...') ) if not message is None: if message != last_message: last_message = message urgency = pynotify.URGENCY_NORMAL icon_name = gtk.STOCK_SAVE status_icon_blinking = False if last_message[0] != 0: urgency = pynotify.URGENCY_CRITICAL icon_name = 'dialog-error' status_icon_blinking = True status_icon.set_blinking( status_icon_blinking ) status_icon.set_tooltip( last_message[1] ) self.notification.update( self.cfg.APP_NAME, last_message[1], icon_name ) self.notification.set_urgency( urgency ) if last_message[0] != 0 and first_error: first_error = False self.notification.set_timeout( 10000 ) self.notification.show() time.sleep( 0.2 ) status_icon.set_visible( False ) gtk.main_iteration( False ) self.notification.close() pynotify.uninit() logger.info( '[GnomeTakeSnapshotCallback.run] end loop' )
def uinit_pynotify(): pynotify.uninit()
event,arg1,arg2,filename = sys.argv[1:5] else: event,arg1,arg2 = sys.argv[1:4] filename = None if event == 'MSG' and arg1 == 'IN': import pynotify,os,locale encoding = (locale.getdefaultlocale())[1] msg = 'sent you a message.' if SHORT_NICK and '@' in arg2: arg2 = arg2[0:arg2.index('@')] if filename is not None: f = file(filename) msg = f.read() pynotify.init('mcnotify') msgbox = pynotify.Notification(unicode(arg2, encoding),unicode(msg, encoding)) msgbox.set_timeout(3000) msgbox.set_urgency(pynotify.URGENCY_LOW) msgbox.show() if (CMD_MSG_IN): os.system(CMD_MSG_IN + '> /dev/null 2>&1') if filename is not None and os.path.exists(filename): os.remove(filename) pynotify.uninit() # vim:set noet sts=8 sw=8:
def clean(): pynotify.uninit()
def main(): lang = get_language() if is_lang_available(lang) and not is_lang_installed(lang): n = pynotify.Notification( _("Additional Translations"), _("Your system \ support some additional translations but they are not yet installed.")) n.connect("closed", quit_notify) n.set_urgency(pynotify.URGENCY_NORMAL) n.set_timeout(pynotify.EXPIRES_NEVER) n.add_action("install", _("Install Now"), install, lang) try: helper = gtk.Button() icon = helper.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) n.set_icon_from_pixbuf(icon) except: print _("Can't load the icon for notification") n.show() MAIN_LOOP.run() if __name__ == '__main__': pynotify.init(APP_NAME) main() pynotify.uninit()