Samuel de Oliveira
Samuel de Oliveira

Reputation: 5

I'm trying to send notifications with Python but the D-bus connection isn't working

I've installed a library called plyer and this library uses the D-bus. But for one reason when I try run this code:

from plyer import notification


if __name__ == "__main__":
    notification.notify(
            title    = 'Hello, world!',
            message  = 'Hello, world!',
            app_icon = None,
            timeout  = 10
            )

gives me this error:

ERROR:dbus.connection:Unable to set arguments ('', 0, None, 'Hello, world!', 'Hello, world!', [], {}, 10000) according to signature 'susssasa{sv}i': <class 'TypeError'>: Expected a string or unicode object
Traceback (most recent call last):
  File "/home/samuel/Clones/__Pull_tests/test.py", line 5, in <module>
    notification.notify(
  File "/usr/lib/python3.10/site-packages/plyer/facades/notification.py", line 84, in notify
    self._notify(
  File "/usr/lib/python3.10/site-packages/plyer/platforms/linux/notification.py", line 81, in _notify
    interface.Notify(
  File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 72, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python3.10/site-packages/dbus/proxies.py", line 141, in __call__
    return self._connection.call_blocking(self._named_service,
  File "/usr/lib/python3.10/site-packages/dbus/connection.py", line 643, in call_blocking
    message.append(signature=signature, *args)
TypeError: Expected a string or unicode object

then I've installed dbus and dbus-python (On Arch Linux) dependencies but nothing is solved, so what do I do?

......................

Upvotes: 0

Views: 475

Answers (1)

ukBaz
ukBaz

Reputation: 7924

According to the signature that None should be string. Have your tried replacing it with an empty string. e.g ''

So your code would be:

from plyer import notification


if __name__ == "__main__":
    notification.notify(
            title    = 'Hello, world!',
            message  = 'Hello, world!',
            app_icon = '',
            timeout  = 10
            )

Upvotes: 1

Related Questions