Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabled transient notifications on Linux #639

Merged
merged 3 commits into from
Jul 6, 2022

Conversation

olumidesan
Copy link
Contributor

Hello!

Transient notifications (notifications that don't persist in the notifications list) are not programmable on Linux, even though they can be. The reason or this is because the hint[s] parameter required by notify-send and dbus cannot be passed to the base Notification.notify() method.

I've implemented a simple solution that allows the other keyword arguments to be passed to the notify() method, allowing the underlying _notify() implementation to use hint[s] and other notification arguments as required.

Currently, trying to use hints with the notify() call fails:

>>> from plyer import notification
>>> print(notification)
<plyer.platforms.linux.notification.NotifyDbus object at 0x7f72cb4d4040>
>>> notification.notify(title="Hello", message="World", hints={'transient':1})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: notify() got an unexpected keyword argument 'hints'

...even though the underlying NotifyDBus implementation clearly supports it:

hints = kwargs.get('hints', [])

With these changes, the transient notifications work as expected.

>>> from plyer import notification
>>> print(notification)
<plyer.platforms.linux.notification.NotifyDbus object at 0x7f39fd5ed520>
>>> notification.notify(title="Hello", message="World", hints={'transient':1})
>>> 

The notify-send implementation also did not support other arguments other than the title and the message. I've added support for hint, urgency, etc., as supported by the notify-send binary itself:

❯ notify-send --help
Usage:
  notify-send [OPTION…] <SUMMARY> [BODY] - create a notification

Help Options:
  -?, --help                        Show help options

Application Options:
  -u, --urgency=LEVEL               Specifies the urgency level (low, normal, critical).
  -t, --expire-time=TIME            Specifies the timeout in milliseconds at which to expire the notification.
  -a, --app-name=APP_NAME           Specifies the app name for the icon
  -i, --icon=ICON[,ICON...]         Specifies an icon filename or stock icon to display.
  -c, --category=TYPE[,TYPE...]     Specifies the notification category.
  -h, --hint=TYPE:NAME:VALUE        Specifies basic extra data to pass. Valid types are int, double, string and byte.
  -v, --version                     Version of the package.

@olumidesan olumidesan changed the title Allow transient notifications in Linux Allow transient notifications on Linux Jul 4, 2021
@olumidesan olumidesan changed the title Allow transient notifications on Linux Enabled transient notifications on Linux Jul 4, 2021
@akshayaurora akshayaurora merged commit bdba28b into kivy:master Jul 6, 2022
@akshayaurora
Copy link
Member

@olumidesan Apologies for the delay. 👍

This was referenced Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants