py3notifier 0.2__py3-none-any.whl
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.
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
|
|
3
|
+
from threading import Thread, Timer
|
|
4
|
+
|
|
5
|
+
from gi.repository import Gio, GLib
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Py3status:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.urgency = 0
|
|
11
|
+
self.num_notifications = 0
|
|
12
|
+
self.single_line = ""
|
|
13
|
+
self.timer = None
|
|
14
|
+
|
|
15
|
+
def post_config_hook(self):
|
|
16
|
+
self._init_dbus()
|
|
17
|
+
self.proxy.call(
|
|
18
|
+
"SignalNotificationCount", None, Gio.DBusCallFlags.NO_AUTO_START, 500, None
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
def _init_dbus(self):
|
|
22
|
+
def clear_msg(py3):
|
|
23
|
+
py3.single_line = ""
|
|
24
|
+
py3.py3.update()
|
|
25
|
+
|
|
26
|
+
def update(py3, *args):
|
|
27
|
+
mode, num, urgency, msg = args[-1]
|
|
28
|
+
py3.num_notifications = num
|
|
29
|
+
py3.urgency = urgency
|
|
30
|
+
|
|
31
|
+
if self.timer is not None:
|
|
32
|
+
self.timer.cancel()
|
|
33
|
+
|
|
34
|
+
py3.single_line = msg
|
|
35
|
+
|
|
36
|
+
if mode == 0: # notification added
|
|
37
|
+
self.timer = Timer(30, clear_msg, (self,)).start()
|
|
38
|
+
|
|
39
|
+
py3.py3.update()
|
|
40
|
+
|
|
41
|
+
self.bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
|
|
42
|
+
self.bus.signal_subscribe(
|
|
43
|
+
None,
|
|
44
|
+
"org.freedesktop.Notifications",
|
|
45
|
+
"NotificationsUpdated",
|
|
46
|
+
None,
|
|
47
|
+
None,
|
|
48
|
+
0,
|
|
49
|
+
lambda *args: update(self, *args),
|
|
50
|
+
)
|
|
51
|
+
self.proxy = Gio.DBusProxy.new_sync(
|
|
52
|
+
self.bus,
|
|
53
|
+
Gio.DBusProxyFlags.NONE,
|
|
54
|
+
None,
|
|
55
|
+
"org.freedesktop.Notifications",
|
|
56
|
+
"/org/freedesktop/Notifications",
|
|
57
|
+
"org.freedesktop.Notifications",
|
|
58
|
+
None,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
thread = Thread(target=lambda: GLib.MainLoop().run())
|
|
62
|
+
thread.daemon = True
|
|
63
|
+
thread.start()
|
|
64
|
+
|
|
65
|
+
def notifications(self):
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
"cached_until": self.py3.CACHE_FOREVER,
|
|
69
|
+
"full_text": self.single_line or str(self.num_notifications),
|
|
70
|
+
"urgent": self.urgency == 2,
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
def on_click(self, event):
|
|
74
|
+
self.single_line = None
|
|
75
|
+
self.proxy.call(
|
|
76
|
+
"ShowNotifications", None, Gio.DBusCallFlags.NO_AUTO_START, 500, None
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return self.notifications()
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if __name__ == "__main__":
|
|
83
|
+
"""
|
|
84
|
+
Run module in test mode.
|
|
85
|
+
"""
|
|
86
|
+
from py3status.module_test import module_test
|
|
87
|
+
|
|
88
|
+
module_test(Py3status)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
py3notifier/notifications.py,sha256=1AwdaZf1s_yTCCihrg2YspFUNgc40jenB0hTc6EKOYY,2269
|
|
2
|
+
py3notifier-0.2.dist-info/METADATA,sha256=RFpqUXS7U6v_rVFRchqble0pic0OKEamd7ni1EW2nUE,117
|
|
3
|
+
py3notifier-0.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
4
|
+
py3notifier-0.2.dist-info/entry_points.txt,sha256=CdJK2rc-ORRbR0Oem-rZGmenH610CyWamrkRMlODWHg,54
|
|
5
|
+
py3notifier-0.2.dist-info/top_level.txt,sha256=kxzgNa5GricuBn62yS_MgvaFpCcm1ev68muBXz5j7s8,12
|
|
6
|
+
py3notifier-0.2.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
py3notifier
|