desktop-notifier 5.0.0.dev0__tar.gz → 5.0.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {desktop_notifier-5.0.0.dev0/src/desktop_notifier.egg-info → desktop_notifier-5.0.0.dev1}/PKG-INFO +2 -2
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/pyproject.toml +2 -2
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/__init__.py +1 -1
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/base.py +4 -1
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/dbus.py +48 -10
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/dummy.py +7 -2
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/macos.py +33 -52
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/main.py +12 -17
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1/src/desktop_notifier.egg-info}/PKG-INFO +2 -2
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier.egg-info/requires.txt +1 -1
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/LICENSE +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/README.md +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/setup.cfg +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/macos_support.py +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/py.typed +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/resources/__init__.py +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/resources/python.png +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/winrt.py +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier.egg-info/SOURCES.txt +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier.egg-info/dependency_links.txt +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier.egg-info/top_level.txt +0 -0
- {desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/tests/test_api.py +0 -0
{desktop_notifier-5.0.0.dev0/src/desktop_notifier.egg-info → desktop_notifier-5.0.0.dev1}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: desktop-notifier
|
|
3
|
-
Version: 5.0.0.
|
|
3
|
+
Version: 5.0.0.dev1
|
|
4
4
|
Summary: Python library for cross-platform desktop notifications
|
|
5
5
|
Author-email: Sam Schott <sam.schott@outlook.com>
|
|
6
6
|
License: MIT
|
|
@@ -41,7 +41,7 @@ Requires-Dist: pytest-cov; extra == "dev"
|
|
|
41
41
|
Provides-Extra: docs
|
|
42
42
|
Requires-Dist: furo==2024.5.6; extra == "docs"
|
|
43
43
|
Requires-Dist: sphinx==7.3.7; extra == "docs"
|
|
44
|
-
Requires-Dist: sphinx-autoapi==3.1.
|
|
44
|
+
Requires-Dist: sphinx-autoapi==3.1.2; extra == "docs"
|
|
45
45
|
Requires-Dist: sphinx-mdinclude==0.6.1; extra == "docs"
|
|
46
46
|
|
|
47
47
|
[](https://pypi.org/project/desktop-notifier/)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "desktop-notifier"
|
|
7
|
-
version = "5.0.0.
|
|
7
|
+
version = "5.0.0.dev1"
|
|
8
8
|
authors = [{name = "Sam Schott", email = "sam.schott@outlook.com"}]
|
|
9
9
|
license = {text = "MIT"}
|
|
10
10
|
description = "Python library for cross-platform desktop notifications"
|
|
@@ -56,7 +56,7 @@ dev = [
|
|
|
56
56
|
docs = [
|
|
57
57
|
"furo==2024.5.6",
|
|
58
58
|
"sphinx==7.3.7",
|
|
59
|
-
"sphinx-autoapi==3.1.
|
|
59
|
+
"sphinx-autoapi==3.1.2",
|
|
60
60
|
"sphinx-mdinclude==0.6.1",
|
|
61
61
|
]
|
|
62
62
|
|
|
@@ -322,7 +322,10 @@ class Notification:
|
|
|
322
322
|
self._identifier = nid
|
|
323
323
|
|
|
324
324
|
def __repr__(self) -> str:
|
|
325
|
-
return
|
|
325
|
+
return (
|
|
326
|
+
f"<{self.__class__.__name__}(identifier='{self.identifier}', "
|
|
327
|
+
f"title='{self.title}', message='{self.message}')>"
|
|
328
|
+
)
|
|
326
329
|
|
|
327
330
|
|
|
328
331
|
class Capability(Enum):
|
|
@@ -57,12 +57,14 @@ class DBusDesktopNotifier(DesktopNotifierBase):
|
|
|
57
57
|
notification center.
|
|
58
58
|
"""
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
to_native_urgency = {
|
|
61
61
|
Urgency.Low: Variant("y", 0),
|
|
62
62
|
Urgency.Normal: Variant("y", 1),
|
|
63
63
|
Urgency.Critical: Variant("y", 2),
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
supported_hint_signatures = {"a{sv}", "a{ss}"}
|
|
67
|
+
|
|
66
68
|
def __init__(
|
|
67
69
|
self,
|
|
68
70
|
app_name: str = "Python",
|
|
@@ -102,13 +104,9 @@ class DBusDesktopNotifier(DesktopNotifierBase):
|
|
|
102
104
|
# Some older interfaces may not support notification actions.
|
|
103
105
|
if hasattr(self.interface, "on_notification_closed"):
|
|
104
106
|
self.interface.on_notification_closed(self._on_closed)
|
|
105
|
-
else:
|
|
106
|
-
logger.warning("on_closed callbacks not supported")
|
|
107
107
|
|
|
108
108
|
if hasattr(self.interface, "on_action_invoked"):
|
|
109
109
|
self.interface.on_action_invoked(self._on_action)
|
|
110
|
-
else:
|
|
111
|
-
logger.warning("on_action_invoked callbacks not supported")
|
|
112
110
|
|
|
113
111
|
return self.interface
|
|
114
112
|
|
|
@@ -131,7 +129,7 @@ class DBusDesktopNotifier(DesktopNotifierBase):
|
|
|
131
129
|
else:
|
|
132
130
|
replaces_nid = 0
|
|
133
131
|
|
|
134
|
-
actions = []
|
|
132
|
+
actions: list[str] = []
|
|
135
133
|
|
|
136
134
|
if notification.on_clicked:
|
|
137
135
|
# The "default" action is typically invoked when clicking on the
|
|
@@ -145,16 +143,37 @@ class DBusDesktopNotifier(DesktopNotifierBase):
|
|
|
145
143
|
for n, button in enumerate(notification.buttons):
|
|
146
144
|
actions += [str(n), button.title]
|
|
147
145
|
|
|
148
|
-
|
|
146
|
+
hints_v: dict[str, Variant] = dict()
|
|
147
|
+
hints_v["urgency"] = self.to_native_urgency[notification.urgency]
|
|
149
148
|
|
|
150
149
|
if notification.sound:
|
|
151
150
|
if notification.sound.is_named():
|
|
152
|
-
|
|
151
|
+
hints_v["sound-name"] = Variant("s", "message-new-instant")
|
|
153
152
|
else:
|
|
154
|
-
|
|
153
|
+
hints_v["sound-file"] = Variant("s", notification.sound.as_uri())
|
|
155
154
|
|
|
156
155
|
if notification.attachment:
|
|
157
|
-
|
|
156
|
+
hints_v["image-path"] = Variant("s", notification.attachment.as_uri())
|
|
157
|
+
|
|
158
|
+
# The current notification spec defines hints as a Dbus dictionary type 'a{sv}',
|
|
159
|
+
# represented in Python as dict[str, Variant]. However, some older notification
|
|
160
|
+
# servers expect 'a{ss}' (Python dict[str, str]). We therefore check the
|
|
161
|
+
# expected argument type at runtime and cast arguments accordingly.
|
|
162
|
+
# See https://github.com/samschott/desktop-notifier/issues/143.
|
|
163
|
+
hints_signature = get_hints_signature(self.interface)
|
|
164
|
+
|
|
165
|
+
if hints_signature == "":
|
|
166
|
+
logger.warning("Notification server not supported")
|
|
167
|
+
return
|
|
168
|
+
|
|
169
|
+
hints: dict[str, str] | dict[str, Variant]
|
|
170
|
+
|
|
171
|
+
if hints_signature == "a{sv}":
|
|
172
|
+
hints = hints_v
|
|
173
|
+
elif hints_signature == "a{ss}":
|
|
174
|
+
hints = {k: str(v.value) for k, v in hints_v.items()}
|
|
175
|
+
else:
|
|
176
|
+
hints = {}
|
|
158
177
|
|
|
159
178
|
timeout = notification.timeout * 1000 if notification.timeout != -1 else -1
|
|
160
179
|
if notification.icon:
|
|
@@ -267,6 +286,7 @@ class DBusDesktopNotifier(DesktopNotifierBase):
|
|
|
267
286
|
Capability.ICON,
|
|
268
287
|
Capability.TITLE,
|
|
269
288
|
Capability.TIMEOUT,
|
|
289
|
+
Capability.URGENCY,
|
|
270
290
|
}
|
|
271
291
|
|
|
272
292
|
# Capabilities supported by some notification servers.
|
|
@@ -284,4 +304,22 @@ class DBusDesktopNotifier(DesktopNotifierBase):
|
|
|
284
304
|
capabilities.add(Capability.SOUND)
|
|
285
305
|
capabilities.add(Capability.SOUND_NAME)
|
|
286
306
|
|
|
307
|
+
hints_signature = get_hints_signature(self.interface)
|
|
308
|
+
if hints_signature not in self.supported_hint_signatures:
|
|
309
|
+
# Any hint-based capabilities are not supported because we got an unexpected
|
|
310
|
+
# DBus interface.
|
|
311
|
+
capabilities.discard(Capability.SOUND)
|
|
312
|
+
capabilities.discard(Capability.SOUND_NAME)
|
|
313
|
+
capabilities.discard(Capability.URGENCY)
|
|
314
|
+
|
|
287
315
|
return frozenset(capabilities)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def get_hints_signature(interface: ProxyInterface) -> str:
|
|
319
|
+
"""Returns the dbus type signature for the hints argument"""
|
|
320
|
+
methods = interface.introspection.methods
|
|
321
|
+
notify_method = next(m for m in methods if m.name == "Notify")
|
|
322
|
+
try:
|
|
323
|
+
return str(notify_method.in_args[6].signature)
|
|
324
|
+
except IndexError:
|
|
325
|
+
return ""
|
|
@@ -5,7 +5,9 @@ Dummy backend for unsupported platforms
|
|
|
5
5
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
import uuid
|
|
9
|
+
|
|
10
|
+
from . import Capability
|
|
9
11
|
from .base import Notification, DesktopNotifierBase
|
|
10
12
|
|
|
11
13
|
|
|
@@ -38,10 +40,13 @@ class DummyNotificationCenter(DesktopNotifierBase):
|
|
|
38
40
|
notification: Notification,
|
|
39
41
|
notification_to_replace: Notification | None,
|
|
40
42
|
) -> None:
|
|
41
|
-
|
|
43
|
+
notification.identifier = str(uuid.uuid4())
|
|
42
44
|
|
|
43
45
|
async def _clear(self, notification: Notification) -> None:
|
|
44
46
|
pass
|
|
45
47
|
|
|
46
48
|
async def _clear_all(self) -> None:
|
|
47
49
|
pass
|
|
50
|
+
|
|
51
|
+
async def get_capabilities(self) -> frozenset[Capability]:
|
|
52
|
+
return frozenset()
|
|
@@ -28,7 +28,6 @@ from rubicon.objc.runtime import load_library, objc_id, objc_block
|
|
|
28
28
|
from .base import (
|
|
29
29
|
Notification,
|
|
30
30
|
DesktopNotifierBase,
|
|
31
|
-
AuthorisationError,
|
|
32
31
|
Urgency,
|
|
33
32
|
Capability,
|
|
34
33
|
DEFAULT_SOUND,
|
|
@@ -82,20 +81,6 @@ UNAuthorizationStatusAuthorized = 2
|
|
|
82
81
|
UNAuthorizationStatusProvisional = 3
|
|
83
82
|
UNAuthorizationStatusEphemeral = 4
|
|
84
83
|
|
|
85
|
-
UNErrorDomain = "UNErrorDomain"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
class UNErrorCode(enum.Enum):
|
|
89
|
-
NotificationsNotAllowed = 1
|
|
90
|
-
AttachmentInvalidURL = 100
|
|
91
|
-
AttachmentUnrecognizedType = 101
|
|
92
|
-
AttachmentInvalidFileSize = 102
|
|
93
|
-
AttachmentNotInDataStore = 103
|
|
94
|
-
AttachmentMoveIntoDataStoreFailed = 104
|
|
95
|
-
AttachmentCorrupt = 105
|
|
96
|
-
NotificationInvalidNoDate = 1400
|
|
97
|
-
NotificationInvalidNoContent = 1401
|
|
98
|
-
|
|
99
84
|
|
|
100
85
|
class UNNotificationInterruptionLevel(enum.Enum):
|
|
101
86
|
Passive = 0
|
|
@@ -104,7 +89,7 @@ class UNNotificationInterruptionLevel(enum.Enum):
|
|
|
104
89
|
Critical = 3
|
|
105
90
|
|
|
106
91
|
|
|
107
|
-
class NotificationCenterDelegate(NSObject): # type:
|
|
92
|
+
class NotificationCenterDelegate(NSObject): # type:ignore
|
|
108
93
|
"""Delegate to handle user interactions with notifications"""
|
|
109
94
|
|
|
110
95
|
@objc_method # type:ignore
|
|
@@ -187,8 +172,9 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
187
172
|
|
|
188
173
|
def on_auth_completed(granted: bool, error: objc_id) -> None:
|
|
189
174
|
ns_error = py_from_ns(error)
|
|
190
|
-
|
|
191
|
-
|
|
175
|
+
if ns_error:
|
|
176
|
+
ns_error.retain()
|
|
177
|
+
future.set_result((granted, ns_error))
|
|
192
178
|
|
|
193
179
|
self.nc.requestAuthorizationWithOptions(
|
|
194
180
|
UNAuthorizationOptionAlert
|
|
@@ -197,16 +183,17 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
197
183
|
completionHandler=on_auth_completed,
|
|
198
184
|
)
|
|
199
185
|
|
|
200
|
-
|
|
186
|
+
has_authorization, error = await asyncio.wrap_future(future)
|
|
201
187
|
|
|
202
|
-
if
|
|
203
|
-
|
|
188
|
+
if error:
|
|
189
|
+
log_nserror(error, "Authorisation denied")
|
|
190
|
+
error.autorelease() # type:ignore[attr-defined]
|
|
204
191
|
|
|
205
|
-
return
|
|
192
|
+
return has_authorization
|
|
206
193
|
|
|
207
194
|
async def has_authorisation(self) -> bool:
|
|
208
195
|
"""Whether we have authorisation to send notifications."""
|
|
209
|
-
future: Future[UNNotificationSettings] = Future() # type:ignore
|
|
196
|
+
future: Future[UNNotificationSettings] = Future() # type:ignore[valid-type]
|
|
210
197
|
|
|
211
198
|
def handler(settings: objc_id) -> None:
|
|
212
199
|
settings = py_from_ns(settings)
|
|
@@ -216,12 +203,12 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
216
203
|
self.nc.getNotificationSettingsWithCompletionHandler(handler)
|
|
217
204
|
|
|
218
205
|
settings = await asyncio.wrap_future(future)
|
|
219
|
-
authorized = settings.authorizationStatus in ( # type:ignore
|
|
206
|
+
authorized = settings.authorizationStatus in ( # type:ignore[attr-defined]
|
|
220
207
|
UNAuthorizationStatusAuthorized,
|
|
221
208
|
UNAuthorizationStatusProvisional,
|
|
222
209
|
UNAuthorizationStatusEphemeral,
|
|
223
210
|
)
|
|
224
|
-
settings.
|
|
211
|
+
settings.autorelease() # type:ignore[attr-defined]
|
|
225
212
|
|
|
226
213
|
return authorized
|
|
227
214
|
|
|
@@ -283,7 +270,7 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
283
270
|
platform_nid, content=content, trigger=None
|
|
284
271
|
)
|
|
285
272
|
|
|
286
|
-
future: Future[NSError] = Future() # type:ignore
|
|
273
|
+
future: Future[NSError] = Future() # type:ignore[valid-type]
|
|
287
274
|
|
|
288
275
|
def handler(error: objc_id) -> None:
|
|
289
276
|
ns_error = py_from_ns(error)
|
|
@@ -300,27 +287,8 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
300
287
|
error = await asyncio.wrap_future(future)
|
|
301
288
|
|
|
302
289
|
if error:
|
|
303
|
-
error
|
|
304
|
-
|
|
305
|
-
if error.domain == UNErrorDomain: # type:ignore
|
|
306
|
-
if error.code == UNErrorCode.NotificationsNotAllowed: # type:ignore
|
|
307
|
-
raise AuthorisationError("Not authorised")
|
|
308
|
-
elif error.code == UNErrorCode.NotificationInvalidNoDate: # type:ignore
|
|
309
|
-
raise RuntimeError("Missing notification date")
|
|
310
|
-
elif (
|
|
311
|
-
error.code # type:ignore
|
|
312
|
-
== UNErrorCode.NotificationInvalidNoContent
|
|
313
|
-
):
|
|
314
|
-
raise RuntimeError("Missing notification content")
|
|
315
|
-
else:
|
|
316
|
-
# In case of attachment errors, the notification will still be
|
|
317
|
-
# delivered, just without an attachment. We therefore do not raise
|
|
318
|
-
# the error.
|
|
319
|
-
logger.warning(
|
|
320
|
-
f"{error.localizedDescription}: {notification.attachment}" # type:ignore
|
|
321
|
-
)
|
|
322
|
-
else:
|
|
323
|
-
raise RuntimeError(error.localizedDescription) # type:ignore
|
|
290
|
+
log_nserror(error, "Error when scheduling notification")
|
|
291
|
+
error.autorelease() # type:ignore[attr-defined]
|
|
324
292
|
|
|
325
293
|
notification.identifier = platform_nid
|
|
326
294
|
|
|
@@ -344,7 +312,10 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
344
312
|
# Retrieve existing categories. We do not cache this value because it may be
|
|
345
313
|
# modified by other Python processes using desktop-notifier.
|
|
346
314
|
categories = await self._get_notification_categories()
|
|
347
|
-
category_ids = set(
|
|
315
|
+
category_ids = set(
|
|
316
|
+
py_from_ns(c.identifier)
|
|
317
|
+
for c in categories.allObjects() # type:ignore[attr-defined]
|
|
318
|
+
)
|
|
348
319
|
|
|
349
320
|
# Register new category if necessary.
|
|
350
321
|
if category_id not in category_ids:
|
|
@@ -368,7 +339,7 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
368
339
|
actions.append(action)
|
|
369
340
|
|
|
370
341
|
# Add category for new set of buttons.
|
|
371
|
-
new_categories = categories.setByAddingObject( # type:
|
|
342
|
+
new_categories = categories.setByAddingObject( # type:ignore[attr-defined]
|
|
372
343
|
UNNotificationCategory.categoryWithIdentifier(
|
|
373
344
|
category_id,
|
|
374
345
|
actions=actions,
|
|
@@ -380,9 +351,9 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
380
351
|
|
|
381
352
|
return category_id
|
|
382
353
|
|
|
383
|
-
async def _get_notification_categories(self) -> NSSet: # type:ignore
|
|
354
|
+
async def _get_notification_categories(self) -> NSSet: # type:ignore[valid-type]
|
|
384
355
|
"""Returns the registered notification categories for this app / Python."""
|
|
385
|
-
future: Future[NSSet] = Future() # type:ignore
|
|
356
|
+
future: Future[NSSet] = Future() # type:ignore[valid-type]
|
|
386
357
|
|
|
387
358
|
def handler(categories: objc_id) -> None:
|
|
388
359
|
categories = py_from_ns(categories)
|
|
@@ -392,7 +363,7 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
392
363
|
self.nc.getNotificationCategoriesWithCompletionHandler(handler)
|
|
393
364
|
|
|
394
365
|
categories = await asyncio.wrap_future(future)
|
|
395
|
-
categories.autorelease() # type:ignore
|
|
366
|
+
categories.autorelease() # type:ignore[attr-defined]
|
|
396
367
|
|
|
397
368
|
return categories
|
|
398
369
|
|
|
@@ -433,3 +404,13 @@ class CocoaNotificationCenter(DesktopNotifierBase):
|
|
|
433
404
|
capabilities.add(Capability.URGENCY)
|
|
434
405
|
|
|
435
406
|
return frozenset(capabilities)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
def log_nserror(error: NSError, prefix: str) -> None: # type:ignore[valid-type]
|
|
410
|
+
domain = str(error.domain) # type:ignore[attr-defined]
|
|
411
|
+
code = int(error.code) # type:ignore[attr-defined]
|
|
412
|
+
description = str(error.localizedDescription) # type:ignore[attr-defined]
|
|
413
|
+
|
|
414
|
+
logger.warning(
|
|
415
|
+
"%s: domain=%s, code=%s, description=%s", prefix, domain, code, description
|
|
416
|
+
)
|
|
@@ -166,7 +166,6 @@ class DesktopNotifier:
|
|
|
166
166
|
|
|
167
167
|
self.app_icon = app_icon
|
|
168
168
|
|
|
169
|
-
self._lock = asyncio.Lock()
|
|
170
169
|
self._impl = impl_cls(app_name, notification_limit)
|
|
171
170
|
self._did_request_authorisation = False
|
|
172
171
|
|
|
@@ -211,9 +210,8 @@ class DesktopNotifier:
|
|
|
211
210
|
|
|
212
211
|
:returns: Whether authorisation has been granted.
|
|
213
212
|
"""
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return await self._impl.request_authorisation()
|
|
213
|
+
self._did_request_authorisation = True
|
|
214
|
+
return await self._impl.request_authorisation()
|
|
217
215
|
|
|
218
216
|
async def has_authorisation(self) -> bool:
|
|
219
217
|
"""Returns whether we have authorisation to send notifications."""
|
|
@@ -232,17 +230,16 @@ class DesktopNotifier:
|
|
|
232
230
|
if not notification.icon:
|
|
233
231
|
notification.icon = self.app_icon
|
|
234
232
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
await self.request_authorisation()
|
|
233
|
+
# Ask for authorisation if not already done. On some platforms, this will
|
|
234
|
+
# trigger a system dialog to ask the user for permission.
|
|
235
|
+
if not self._did_request_authorisation:
|
|
236
|
+
await self.request_authorisation()
|
|
240
237
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
238
|
+
# We attempt to send the notification regardless of authorization.
|
|
239
|
+
# The user may have changed settings in the meantime.
|
|
240
|
+
await self._impl.send(notification)
|
|
244
241
|
|
|
245
|
-
|
|
242
|
+
return notification
|
|
246
243
|
|
|
247
244
|
async def send(
|
|
248
245
|
self,
|
|
@@ -348,16 +345,14 @@ class DesktopNotifier:
|
|
|
348
345
|
|
|
349
346
|
:param notification: Notification to clear.
|
|
350
347
|
"""
|
|
351
|
-
|
|
352
|
-
await self._impl.clear(notification)
|
|
348
|
+
await self._impl.clear(notification)
|
|
353
349
|
|
|
354
350
|
async def clear_all(self) -> None:
|
|
355
351
|
"""
|
|
356
352
|
Removes all currently displayed notifications for this app from the notification
|
|
357
353
|
center.
|
|
358
354
|
"""
|
|
359
|
-
|
|
360
|
-
await self._impl.clear_all()
|
|
355
|
+
await self._impl.clear_all()
|
|
361
356
|
|
|
362
357
|
@property
|
|
363
358
|
def capabilities(self) -> frozenset[Capability]:
|
{desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1/src/desktop_notifier.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: desktop-notifier
|
|
3
|
-
Version: 5.0.0.
|
|
3
|
+
Version: 5.0.0.dev1
|
|
4
4
|
Summary: Python library for cross-platform desktop notifications
|
|
5
5
|
Author-email: Sam Schott <sam.schott@outlook.com>
|
|
6
6
|
License: MIT
|
|
@@ -41,7 +41,7 @@ Requires-Dist: pytest-cov; extra == "dev"
|
|
|
41
41
|
Provides-Extra: docs
|
|
42
42
|
Requires-Dist: furo==2024.5.6; extra == "docs"
|
|
43
43
|
Requires-Dist: sphinx==7.3.7; extra == "docs"
|
|
44
|
-
Requires-Dist: sphinx-autoapi==3.1.
|
|
44
|
+
Requires-Dist: sphinx-autoapi==3.1.2; extra == "docs"
|
|
45
45
|
Requires-Dist: sphinx-mdinclude==0.6.1; extra == "docs"
|
|
46
46
|
|
|
47
47
|
[](https://pypi.org/project/desktop-notifier/)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{desktop_notifier-5.0.0.dev0 → desktop_notifier-5.0.0.dev1}/src/desktop_notifier/macos_support.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|