2222from pathlib import Path
2323from typing import Any , Dict , List , Optional , Tuple , Union
2424
25- from sdbus import (DbusInterfaceCommonAsync , dbus_method_async ,
26- dbus_signal_async )
25+ from sdbus import (
26+ DbusInterfaceCommonAsync ,
27+ DbusUnprivilegedFlag ,
28+ dbus_method_async ,
29+ dbus_signal_async ,
30+ )
2731from sdbus .sd_bus_internals import SdBus
2832
2933
3034class NotificationsInterface (
3135 DbusInterfaceCommonAsync ,
3236 interface_name = 'org.freedesktop.Notifications' ):
3337
34- @dbus_method_async ('u' )
38+ @dbus_method_async (
39+ input_signature = "u" ,
40+ result_args_names = (),
41+ flags = DbusUnprivilegedFlag ,
42+ )
3543 async def close_notification (self , notif_id : int ) -> None :
3644 """Close notification by id.
3745
3846 :param int notif_id: Notification id to close.
3947 """
4048 raise NotImplementedError
4149
42- @dbus_method_async ()
50+ @dbus_method_async (
51+ result_signature = "as" ,
52+ result_args_names = ('capabilities' ,),
53+ flags = DbusUnprivilegedFlag ,
54+ )
4355 async def get_capabilities (self ) -> List [str ]:
4456 """Returns notification daemon capabilities.
4557
@@ -66,7 +78,16 @@ async def get_capabilities(self) -> List[str]:
6678 """
6779 raise NotImplementedError
6880
69- @dbus_method_async ()
81+ @dbus_method_async (
82+ result_signature = "ssss" ,
83+ result_args_names = (
84+ 'server_name' ,
85+ 'server_vendor' ,
86+ 'version' ,
87+ 'notifications_version' ,
88+ ),
89+ flags = DbusUnprivilegedFlag ,
90+ )
7091 async def get_server_information (self ) -> Tuple [str , str , str , str ]:
7192 """Returns notification server information.
7293
@@ -76,7 +97,12 @@ async def get_server_information(self) -> Tuple[str, str, str, str]:
7697 """
7798 raise NotImplementedError
7899
79- @dbus_method_async ("susssasa{sv}i" )
100+ @dbus_method_async (
101+ input_signature = "susssasa{sv}i" ,
102+ result_signature = "u" ,
103+ result_args_names = ('notif_id' ,),
104+ flags = DbusUnprivilegedFlag ,
105+ )
80106 async def notify (
81107 self ,
82108 app_name : str = '' ,
@@ -97,7 +123,8 @@ async def notify(
97123 :param str summary: Summary of notification.
98124 :param str body: Optional body of notification.
99125 :param List[str] actions: Optional list of actions presented to user. \
100- List index becomes action id.
126+ Should be sent in pairs of strings that represent action \
127+ key identifier and a localized string to be displayed to user.
101128 :param Dict[str,Tuple[str,Any]] hints: Extra options such as sounds \
102129 that can be passed. See :py:meth:`create_hints`.
103130 :param int expire_timeout: Optional notification expiration timeout \
@@ -109,18 +136,23 @@ async def notify(
109136
110137 raise NotImplementedError
111138
112- @dbus_signal_async ()
113- def action_invoked (self ) -> Tuple [int , int ]:
139+ @dbus_signal_async (
140+ signal_signature = "us" ,
141+ signal_args_names = ('notif_id' , 'action_key' ),
142+ )
143+ def action_invoked (self ) -> Tuple [int , str ]:
114144 """Signal when user invokes one of the actions specified.
115145
116146 First element of tuple is notification id.
117147
118- Second element is the index of the action invoked. \
119- Matches the index of passed list of actions.
148+ Second element is the key identifier of the action invoked.
120149 """
121150 raise NotImplementedError
122151
123- @dbus_signal_async ()
152+ @dbus_signal_async (
153+ signal_signature = "uu" ,
154+ signal_args_names = ('notif_id' , 'reason' ),
155+ )
124156 def notification_closed (self ) -> Tuple [int , int ]:
125157 """Signal when notification is closed.
126158
@@ -135,6 +167,24 @@ def notification_closed(self) -> Tuple[int, int]:
135167 """
136168 raise NotImplementedError
137169
170+ @dbus_signal_async (
171+ signal_signature = "us" ,
172+ signal_args_names = ('notif_id' , 'action_key' ),
173+ )
174+ def activation_token (self ) -> Tuple [int , str ]:
175+ """Signal carrying window system token.
176+
177+ Emitted before :py:attr:`action_invoked`.
178+
179+ Carries windowing system token like X11 startup id or
180+ Wayland adctivation token.
181+
182+ First element of tuple is notification id.
183+
184+ Second element is the key identifier of the action invoked.
185+ """
186+ raise NotImplementedError
187+
138188 def create_hints (
139189 self ,
140190 use_action_icons : Optional [bool ] = None ,
0 commit comments