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

Various small improvements and bugfixes #204

Merged
merged 6 commits into from
Nov 30, 2024
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
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
Loading