diff --git a/README.md b/README.md index fdf7a80..087ae5f 100644 --- a/README.md +++ b/README.md @@ -73,10 +73,7 @@ from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField, DEFAU async def main() -> None: - notifier = DesktopNotifier( - app_name="Sample App", - notification_limit=10, - ) + notifier = DesktopNotifier(app_name="Sample App") await notifier.send( title="Julius Caesar", diff --git a/src/desktop_notifier/backends/dbus.py b/src/desktop_notifier/backends/dbus.py index 916ab2f..91638bc 100644 --- a/src/desktop_notifier/backends/dbus.py +++ b/src/desktop_notifier/backends/dbus.py @@ -115,7 +115,7 @@ async def _send(self, notification: Notification) -> None: if notification.sound: if notification.sound.is_named(): - hints_v["sound-name"] = Variant("s", "message-new-instant") + hints_v["sound-name"] = Variant("s", notification.sound.name) else: hints_v["sound-file"] = Variant("s", notification.sound.as_uri()) @@ -172,7 +172,7 @@ async def _clear(self, identifier: str) -> None: Asynchronously removes a notification from the notification center """ if not self.interface: - return + self.interface = await self._init_dbus() platform_id = self._platform_to_interface_notification_identifier.inverse[ identifier @@ -199,9 +199,6 @@ async def _clear_all(self) -> None: """ Asynchronously clears all notifications from notification center """ - if not self.interface: - return - for identifier in list( self._platform_to_interface_notification_identifier.values() ): diff --git a/src/desktop_notifier/main.py b/src/desktop_notifier/main.py index 61c8699..23d1f92 100644 --- a/src/desktop_notifier/main.py +++ b/src/desktop_notifier/main.py @@ -310,7 +310,7 @@ def on_dismissed(self, handler: Callable[[str], Any] | None) -> None: @property def on_button_pressed(self) -> Callable[[str, str], Any] | None: """ - A method to call when a notification is dismissed + A method to call when one of the notification's buttons is clicked The method must take the notification identifier and the button identifier as arguments. diff --git a/src/desktop_notifier/sync.py b/src/desktop_notifier/sync.py index 447f240..307ee1d 100644 --- a/src/desktop_notifier/sync.py +++ b/src/desktop_notifier/sync.py @@ -41,7 +41,7 @@ def __init__( app_icon: Icon | None = DEFAULT_ICON, notification_limit: int | None = None, ) -> None: - self._async_api = DesktopNotifier(app_name, app_icon) + self._async_api = DesktopNotifier(app_name, app_icon, notification_limit) self._loop = asyncio.new_event_loop() def _run_coro_sync(self, coro: Coroutine[None, None, T]) -> T: diff --git a/tests/test_callbacks.py b/tests/test_callbacks.py index 2347e6e..55be0f5 100644 --- a/tests/test_callbacks.py +++ b/tests/test_callbacks.py @@ -25,7 +25,7 @@ async def check_supported(notifier: DesktopNotifier, capability: Capability) -> None: capabilities = await notifier.get_capabilities() if capability not in capabilities: - pytest.skip(f"{notifier} not supported by backend") + pytest.skip(f"{capability} not supported by {notifier} backend") @pytest.mark.asyncio