Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions plyer/facades/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -58,13 +58,16 @@ 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
:type app_icon: str
: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
Expand All @@ -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
Expand Down
24 changes: 20 additions & 4 deletions plyer/platforms/linux/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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'
Expand Down