Skip to content

Commit

Permalink
Merge pull request #204 from PhrozenByte/bugfix/misc-20241125
Browse files Browse the repository at this point in the history
Various small improvements and bugfixes
  • Loading branch information
samschott authored Nov 30, 2024
2 parents ff32314 + c539338 commit b3961fe
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 12 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 2 additions & 5 deletions src/desktop_notifier/backends/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down Expand Up @@ -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
Expand All @@ -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()
):
Expand Down
2 changes: 1 addition & 1 deletion src/desktop_notifier/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/desktop_notifier/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3961fe

Please sign in to comment.