diff --git a/plyer/facades/notification.py b/plyer/facades/notification.py index b35f591a5..904094f0e 100644 --- a/plyer/facades/notification.py +++ b/plyer/facades/notification.py @@ -46,7 +46,7 @@ class Notification: ''' def notify(self, title='', message='', app_name='', app_icon='', - timeout=10, ticker='', toast=False): + timeout=10, ticker='', toast=False, hints={}): ''' Send a notification. @@ -58,6 +58,8 @@ def notify(self, title='', message='', app_name='', app_icon='', :param ticker: text to display on status bar as the notification arrives :param toast: simple Android message instead of full notification + :param hints: Optional hints that can be used to pass along extra instructions on Linux. (See https://specifications.freedesktop.org/notification-spec/latest/ar01s08.html) + :type title: str :type message: str :type app_name: str @@ -65,6 +67,7 @@ def notify(self, title='', message='', app_name='', app_icon='', :type timeout: int :type ticker: str :type toast: bool + :type hints: dict .. note:: When called on Windows, ``app_icon`` has to be a path to @@ -79,7 +82,7 @@ def notify(self, title='', message='', app_name='', app_icon='', self._notify( title=title, message=message, app_icon=app_icon, app_name=app_name, - timeout=timeout, ticker=ticker, toast=toast + timeout=timeout, ticker=ticker, toast=toast, hints=hints ) # private diff --git a/plyer/platforms/linux/notification.py b/plyer/platforms/linux/notification.py index b35ca066a..c1aa1d796 100644 --- a/plyer/platforms/linux/notification.py +++ b/plyer/platforms/linux/notification.py @@ -14,9 +14,25 @@ class NotifySendNotification(Notification): using notify-send binary. ''' def _notify(self, **kwargs): - subprocess.call([ - "notify-send", kwargs.get('title'), kwargs.get('message') - ]) + icon = kwargs.get('icon', '') + title = kwargs.get('title', 'title') + hint = kwargs.get('hint', 'string::') + message = kwargs.get('message', 'body') + category = kwargs.get('category', '') + app_name = kwargs.get('app_name', '') + urgency = kwargs.get('urgency', 'normal') + expire_time = kwargs.get('expire_time', '0') + + notify_send_args = (title, + message, + "-i", icon, + "-h", hint, + "-u", urgency, + "-c", category, + "-a", app_name, + "-t", expire_time) + + subprocess.call(["notify-send", *notify_send_args]) class NotifyDbus(Notification): @@ -32,7 +48,7 @@ def _notify(self, **kwargs): app_icon = kwargs.get('app_icon', '') timeout = kwargs.get('timeout', 10) actions = kwargs.get('actions', []) - hints = kwargs.get('hints', []) + hints = kwargs.get('hints', {}) replaces_id = kwargs.get('replaces_id', 0) _bus_name = 'org.freedesktop.Notifications'