1import sys
2
3sys.excepthook =  sys.__excepthook__
4
5import trio
6
7from jeepney import MessageGenerator, new_method_call
8from jeepney.io.trio import open_dbus_router, Proxy
9
10# ---- Message generator, created by jeepney.bindgen ----
11class Notifications(MessageGenerator):
12    interface = 'org.freedesktop.Notifications'
13
14    def __init__(self, object_path='/org/freedesktop/Notifications',
15                 bus_name='org.freedesktop.Notifications'):
16        super().__init__(object_path=object_path, bus_name=bus_name)
17
18    def Notify(self, arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7):
19        return new_method_call(self, 'Notify', 'susssasa{sv}i',
20                               (arg_0, arg_1, arg_2, arg_3, arg_4, arg_5, arg_6, arg_7))
21
22    def CloseNotification(self, arg_0):
23        return new_method_call(self, 'CloseNotification', 'u',
24                               (arg_0,))
25
26    def GetCapabilities(self):
27        return new_method_call(self, 'GetCapabilities')
28
29    def GetServerInformation(self):
30        return new_method_call(self, 'GetServerInformation')
31# ---- End auto generated code ----
32
33
34async def send_notification():
35    async with open_dbus_router(bus='SESSION') as req:
36        proxy = Proxy(Notifications(), req)
37
38        resp = await proxy.Notify('jeepney_test',  # App name
39                              0,      # Not replacing any previous notification
40                              '',     # Icon
41                              'Hello, world!',  # Summary
42                              'This is an example notification from Jeepney & Trio',
43                              [], {},  # Actions, hints
44                              -1,      # expire_timeout (-1 = default)
45                             )
46        print('Notification ID:', resp[0])
47
48if __name__ == '__main__':
49    trio.run(send_notification)
50