Python notify2.Notification() Examples
The following are 21
code examples of notify2.Notification().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
notify2
, or try the search function
.
Example #1
Source File: ui.py From pantalaimon with Apache License 2.0 | 8 votes |
def unverified_notification(self, message): notificaton = notify2.Notification( "Unverified devices.", message=( f"There are unverified devices in the room " f"{message.room_display_name}." ), ) notificaton.set_category("im") def send_cb(notification, action_key, user_data): message = user_data self.control_if.SendAnyways(message.pan_user, message.room_id) def cancel_cb(notification, action_key, user_data): message = user_data self.control_if.CancelSending(message.pan_user, message.room_id) if "actions" in notify2.get_server_caps(): notificaton.add_action("send", "Send anyways", send_cb, message) notificaton.add_action("cancel", "Cancel sending", cancel_cb, message) notificaton.show()
Example #2
Source File: Plugins.py From launcher with GNU General Public License v2.0 | 6 votes |
def installPlugin(self,plugin): destination=os.path.join("/usr/share/duck-launcher/plugins/",plugin) path_to_download= "https://github.com/the-duck/launcher-plugins/trunk/{}".format(str(plugin)) try: subprocess.call(["gksudo", "duck-plugins install --repo {}".format(plugin)]) success=True except Exception as e: success=False if not os.path.isdir(destination): success=False if success==True: n = notify2.Notification("Plugin installation successful", "The plugin <b>{}</b> has been successfully installed".format(plugin), "dialog-information" # Icon nam ) n.show() elif success==False: n = notify2.Notification("Could not install plugin '{}'".format(plugin), "Please check your internet connection", "dialog-error" # Icon name ) n.show()
Example #3
Source File: battery_notifier.py From openrazer with GNU General Public License v2.0 | 6 votes |
def __init__(self, parent, device_id, device_name): super(BatteryNotifier, self).__init__() self._logger = logging.getLogger('razer.device{0}.batterynotifier'.format(device_id)) self._notify2 = notify2 is not None self.event = threading.Event() if self._notify2: try: notify2.init('openrazer_daemon') except Exception as err: self._logger.warning("Failed to init notification daemon, err: {0}".format(err)) self._notify2 = False self._shutdown = False self._device_name = device_name # Could save reference to parent but only need battery level function self._get_battery_func = parent.getBattery if self._notify2: self._notification = notify2.Notification(summary="{0}") self._notification.set_timeout(NOTIFY_TIMEOUT) self._last_notify_time = datetime.datetime(1970, 1, 1)
Example #4
Source File: alarm.py From coinprice-indicator with MIT License | 6 votes |
def __notify(self, price, direction, threshold): exchange_name = self.parent.exchange.get_name() asset_name = self.parent.exchange.asset_pair.get('base') title = asset_name + ' price alert: ' + self.parent.symbol + str(price) message = 'Price on ' + exchange_name + ' ' + direction + ' ' + self.parent.symbol + str(threshold) if notify2.init(self.app_name): if pygame.init(): pygame.mixer.music.load(self.parent.coin.config.get('project_root') + '/resources/ca-ching.wav') pygame.mixer.music.play() logo = GdkPixbuf.Pixbuf.new_from_file( self.parent.coin.config.get('project_root') + '/resources/icon_32px.png') n = notify2.Notification(title, message) n.set_icon_from_pixbuf(logo) n.set_urgency(2) # highest n.show()
Example #5
Source File: coin.py From coinprice-indicator with MIT License | 6 votes |
def update_assets(self): self.discoveries += 1 if self.discoveries < len([ex for ex in self.EXCHANGES if ex.active and ex.discovery]): return # wait until all active exchanges with discovery finish discovery self.discoveries = 0 self._load_assets() if notify2.init(self.config.get('app').get('name')): n = notify2.Notification( self.config.get('app').get('name'), "Finished discovering new assets", self.icon) n.set_urgency(1) n.timeout = 2000 n.show() self.main_item.set_icon_full(self.icon, "App icon") # Handle system resume by refreshing all tickers
Example #6
Source File: windowManager.py From Tickeys-linux with MIT License | 6 votes |
def show_GUI(): def show_notify(): try: import notify2 notify2.init('Tickeys') title = 'Tickeys' body = '程序“xdotool”尚未安装, 无法隐藏窗口。' iconfile = os.getcwd() + '/tickeys.png' notify = notify2.Notification(title, body, iconfile) notify.show() except Exception: return try: GUIID = read_GUI_window_id() if not GUIID or GUIID == "0": Thread(target=show_notify).start() return else: # read window ids command = "xdotool windowmap --sync %s && xdotool windowactivate --sync %s" % (GUIID, GUIID) stat, output = commands.getstatusoutput(command) return str(stat) except Exception, e: logger.error(str(e)) return '256'
Example #7
Source File: Plugins.py From launcher with GNU General Public License v2.0 | 6 votes |
def removePlugin(self, plugin): destination=os.path.join("/usr/share/duck-launcher/plugins/",plugin) try: subprocess.call(["gksudo", "duck-plugins remove {}".format(plugin)]) success=True except Exception: success=False if os.path.isdir(destination): success==False if success==True: n = notify2.Notification("The plugin'{}' has been successfully removed".format(plugin), "", "dialog-information" # Icon nam ) n.show() elif success==False: n = notify2.Notification("Could not remove plugin '{}'".format(plugin), "Please report this bug", "dialog-error" # Icon name ) n.show()
Example #8
Source File: Main.py From Crypto-Notifier with MIT License | 6 votes |
def notify(): icon_path = "/home/dushyant/Desktop/Github/Crypto-Notifier/logo.jpg" cryptocurrencies = ["BTC", "ETH", "LTC", "XMR", "XRP",] result = "\n" for coin in cryptocurrencies: rate = fetch_coin(coin, "USD") result += "{} - {}\n".format(coin, "$"+str(rate)) # print result notify2.init("Cryptocurrency rates notifier") n = notify2.Notification("Crypto Notifier", icon=icon_path) n.set_urgency(notify2.URGENCY_NORMAL) n.set_timeout(1000) n.update("Current Cryptocurrency Rates", result) n.show()
Example #9
Source File: Main.py From Crypto-Notifier with MIT License | 6 votes |
def notify(): icon_path = "/home/dushyant/Desktop/Github/Crypto-Notifier/logo.jpg" cryptocurrencies = ["BTC", "ETH", "LTC", "XMR", "XRP",] result = "\n" for coin in cryptocurrencies: rate = fetch_coin(coin, "USD") result += "{} - {}\n".format(coin, "$"+str(rate)) # print result notify2.init("Cryptocurrency rates notifier") n = notify2.Notification("Crypto Notifier", icon=icon_path) n.set_urgency(notify2.URGENCY_NORMAL) n.set_timeout(1000) n.update("Current Cryptocurrency Rates", result) n.show()
Example #10
Source File: Widgets.py From launcher with GNU General Public License v2.0 | 5 votes |
def _pluginInstallPlugin(self,plugin): notify2.init("duck-launcher") n=notify2.Notification("The plugin '{}' is installing".format(plugin), "", "dialog-information") n.show() self.parent.close_it() t = installPlugin(parent=self.parent) t.plugin=plugin t.start() self.parent.close_it()
Example #11
Source File: Widgets.py From launcher with GNU General Public License v2.0 | 5 votes |
def _pluginRemovePlugin(self,plugin): notify2.init("duck-launcher") n=notify2.Notification("The plugin '{}' is uninstalling".format(plugin), "", "dialog-information") n.show() self.parent.close_it() t = removePlugin(parent=self.parent) t.plugin=plugin t.start()
Example #12
Source File: notification.py From pulseaudio-dlna with GNU General Public License v3.0 | 5 votes |
def show(title, message, icon=''): try: notice = notify2.Notification(title, message, icon) notice.set_timeout(notify2.EXPIRES_DEFAULT) notice.show() except: logger.info( 'notify2 failed to display: {title} - {message}'.format( title=title, message=message))
Example #13
Source File: daemon.py From sun with GNU General Public License v3.0 | 5 votes |
def __init__(self): notify2.uninit() notify2.init('sun') self.pkg_count = len(fetch()) self.summary = f"{' ' * 10}Software Updates" self.message = f"{' ' * 3}{self.pkg_count} Software updates are available\n" self.icon = f'{icon_path}{__all__}.png' self.n = notify2.Notification(self.summary, self.message, self.icon) self.n.set_timeout(60000 * int(config()['STANDBY']))
Example #14
Source File: handlers.py From pyrdp with GNU General Public License v3.0 | 5 votes |
def emit(self, record): """ Send a notification. :param record: the LogRecord object """ notification = notify2.Notification(record.getMessage()) notification.show()
Example #15
Source File: by_desktop.py From UoM-WAM-Spam with MIT License | 5 votes |
def __init__(self) -> None: print("Configuring Desktop Notifier...") notify2.init("UoM-WAM-Spam") self.notification = notify2.Notification self.timeout = notify2.EXPIRES_NEVER
Example #16
Source File: main.py From smd with MIT License | 5 votes |
def send(message, error=False, downloaded=True): try: ns = notify2.Notification(f'{"Downloaded" if downloaded else "Start downloading"}', message=message, icon=notify.image) # Set the urgency level ns.set_urgency(notify2.URGENCY_NORMAL) # Set the timeout ns.set_timeout(5000) notify.sound(error) ns.show() except:pass
Example #17
Source File: ui.py From pantalaimon with Apache License 2.0 | 5 votes |
def sas_done_notification(self, message): notificaton = notify2.Notification( "Device successfully verified.", message=( f"Device {message.device_id} of user {message.user_id} " f"successfully verified." ), ) notificaton.set_category("im") notificaton.show()
Example #18
Source File: ui.py From pantalaimon with Apache License 2.0 | 5 votes |
def sas_invite_notification(self, message): notificaton = notify2.Notification( "Key verification invite", message=( f"{message.user_id} via {message.device_id} has started " f"a key verification process." ), ) notificaton.set_category("im") def accept_cb(notification, action_key, user_data): message = user_data self.device_if.AcceptKeyVerification( message.pan_user, message.user_id, message.device_id ) def cancel_cb(notification, action_key, user_data): message = user_data self.device_if.CancelKeyVerification( message.pan_user, message.user_id, message.device_id ) if "actions" in notify2.get_server_caps(): notificaton.add_action("accept", "Accept", accept_cb, message) notificaton.add_action("cancel", "Cancel", cancel_cb, message) notificaton.show()
Example #19
Source File: dbus_notify.py From process-watcher with MIT License | 5 votes |
def send(process=None, subject_format='{executable} process {pid} ended', timeout=notify2.EXPIRES_NEVER): """Display a Desktop Notification via DBUS (notify2) :param process: information about process. (.info() inserted into body) :param subject_format: subject format string. (uses process.__dict__) :param timeout: how long to display notification (milliseconds) default 0 (never expires) """ notif = Notification(subject_format.format(**process.__dict__), process.info()) notif.timeout = timeout notif.show()
Example #20
Source File: GUI.py From Tickeys-linux with MIT License | 4 votes |
def show_notify(notify_content=""): try: notify2.init('Tickeys') title = 'Tickeys' icon_file_path = os.getcwd() + '/tickeys.png' notify = notify2.Notification(title, notify_content, icon_file_path) notify.show() except Exception, e: logger.exception(e) logger.error("show notify fail")
Example #21
Source File: ui.py From pantalaimon with Apache License 2.0 | 4 votes |
def sas_show_notification(self, message): emojis = [x[0] for x in message.emoji] emoji_str = " ".join(emojis) notificaton = notify2.Notification( "Short authentication string", message=( f"Short authentication string for the key verification of" f" {message.user_id} via {message.device_id}:\n" f"{emoji_str}" ), ) notificaton.set_category("im") def confirm_cb(notification, action_key, user_data): message = user_data self.device_if.ConfirmKeyVerification( message.pan_user, message.user_id, message.device_id ) def cancel_cb(notification, action_key, user_data): message = user_data self.device_if.CancelKeyVerification( message.pan_user, message.user_id, message.device_id ) if "actions" in notify2.get_server_caps(): notificaton.add_action("confirm", "Confirm", confirm_cb, message) notificaton.add_action("cancel", "Cancel", cancel_cb, message) notificaton.show()