-
Notifications
You must be signed in to change notification settings - Fork 8
/
eventloop.py
43 lines (33 loc) · 1.02 KB
/
eventloop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import asyncio
import platform
from desktop_notifier import DesktopNotifier, Urgency, Button, ReplyField
notify = DesktopNotifier(
app_name="Sample App",
notification_limit=10,
)
async def main() -> None:
await notify.send(
title="Julius Caesar",
message="Et tu, Brute?",
urgency=Urgency.Critical,
buttons=[
Button(
title="Mark as read",
on_pressed=lambda: print("Marked as read"),
)
],
reply_field=ReplyField(
title="Reply",
button_title="Send",
on_replied=lambda text: print("Brutus replied:", text),
),
on_clicked=lambda: print("Notification clicked"),
on_dismissed=lambda: print("Notification dismissed"),
sound=True,
)
if platform.system() == "Darwin":
from rubicon.objc.eventloop import EventLoopPolicy
asyncio.set_event_loop_policy(EventLoopPolicy())
loop = asyncio.get_event_loop()
loop.create_task(main())
loop.run_forever()