-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathnotify.py
58 lines (50 loc) · 4.24 KB
/
notify.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
import base64
import sys
import termuxgui as tg
image = base64.standard_b64decode("""iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAFVUlEQVR4XtWaTUhtVRTHl1qZWpkg9mXhy8yejR6BRRMn0uRNUmgQcQfRoIiiSFQQIi1SauigDxokWvEcCBKiBBE9kohI571wpmaPNCuRlx/t1v/ss87Zd+/7sa/3nCMt+HGP96y91tpnr7U/zpWoeqlh6pibw89yYuqi7blJLXOT/WUotzH3MBdCcI3vCglswFZmUijwh5nnmY+Yb5lfmN+YP0Jwje9wDzrQRRtTMukIhl4ETzTHfMX8zagKQRu0hY0misX0kZhInsv1S8zPlB/Qv8ypJ9A128IWbEpNYDQSqw+zMB9nfqDYMYI5Dj/tJ1yOQm1hGz5EfCaFkmIaeJ05odi5XCcBbElHcA1fImfuhNnwA4qd4anZKZAEsAnb8jeKXaTiTpizweekDUr+2o6TxvTzBcW14N0Js3g+JNdoFpj+PqY4Jq/Cljn+NXKNZYnp9w3SYq8/jsgc3Ev5BWsbzwqzsJ8kLUXXCTPvZao0i+q8kBh+pDjGgiu2DM+LpBug92nMNpUiCySuXyEtTipJjxopXmGdeb6hoUGNjY2p1dXVgMXFRdXW1mY7TAOJ5RpzB2nJGwXpUY60YtG87+zsVDs7O+r09DRgenpaNTY2OnopIDG9QFqiUTCnJmyuoFQy9wcHB9Xu7m7QgcPDQzUyMuLopIDE9DXFTz+IXRaILop3lUVHANTX16upqSl1dHQUdGJra0v19fWpmpoaRzdBJCbE+ChpCWKXaQlDAwWvwm1paVErKytRKq2tran29nZHL2EktpdJSxC7jMAn4c2ST9+kq6tLb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earLayout(a)
normalb = tg.Button(a, "Normal notification", root)
expandb = tg.Button(a, "Expandable notification", root)
imgb = tg.Button(a, "Image notification", root)
customb = tg.Button(a, "Custom notification", root)
rv = tg.RemoteViews(c)
cb = rv.addButton()
rv.setText(cb, "Button")
for ev in c.events():
if ev.type == tg.Event.destroy:
sys.exit()
if ev.type == tg.Event.click:
id = ev.value["id"]
if id == normalb:
# Create a new high priority notification in the channel "test"
n = tg.Notification(c, "test", 3)
# Set the text
n.settitle("normal")
n.setcontent("A normal text notification")
# display it
n.notify()
if id == expandb:
n = tg.Notification(c, "test", 3)
n.settitle("expandable")
# sets the expanded text
n.setlargetext("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\nUt enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.\nExcepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
n.notify()
if id == imgb:
n = tg.Notification(c, "test", 3)
n.settitle("image")
n.setcontent("expand to see the image")
# set the image, and display it as a thumbnail when the notification is collapsed
n.setlargeimageasthumbnail(True)
n.setlargeimage(image)
n.notify()
if id == customb:
n = tg.Notification(c, "test", 3)
# Set a custom layout for the notification
n.setlayout(rv)
n.notify()
# catch the event from the button in the custom notification
if ev.type == tg.Event.remoteclick:
c.toast("notification button clicked", True)