class Notifier: """ Notifier class is responsible for creating and managing the notification Args: summary: title of the notification message: message to be displayed icon: icon of notification bar """ def __init__(self, app_name: str, summary: str, message: str = "", icon: str = "") -> None: self._app_name = app_name self._summary = summary self._message = message self._icon = icon notify2.init(self._app_name) self._notification = Notification(self._summary, self._message, self._icon) def show(self, urgency_level: int = notify2.URGENCY_NORMAL) -> None: """ Show notification bar Args: urgency_level: level of urgency (NORMAL, LOW, CRITICAL) """ self._notification.set_urgency(urgency_level) self._notification.show() def close(self) -> None: """ Remove notification bar from tray """ self._notification.close()
def notify(): init('Notify') n = Notification("Drink Water", "Hey asshole, drink some water FFS") n.show() sleep(10) n.close() return True
def on_start(self): if self._should_run(): self._run_command() self.finish_async() else: n = Notification( summary=str(self.command), message="Run now?", # TODO include command name icon='dialog-question', ) n.set_timeout(EXPIRES_NEVER) n.add_action("error", "<b>Run</b>", lambda n, action: self._run_command(n)) n.add_action("close", "Close", lambda n, action: n.close()) n.connect('closed', lambda n: self.finish_async()) n.show()