23 from gi.repository
import GLib, Notify
27 def action_callback(notification, action_id, data):
31 def quit_callback(notification):
35 if __name__ ==
'__main__':
36 parser = argparse.ArgumentParser(
37 description=
'Create an interactive notification'
42 help=
'summary text of the notification',
47 help=
'body text of the notification',
52 help=
'path to the icon to display',
57 help=
'id and label for the callback in the format: id,label',
63 help=
'LOW, NORMAL, CRITICAL',
64 choices=[
'LOW',
'NORMAL',
'CRITICAL'],
69 help=
'list of comma sep options',
74 args = parser.parse_args()
76 Notify.init(
'Interactive Notifications')
78 notification = Notify.Notification.new(args.summary, args.body, args.icon)
80 for hint
in args.hints:
81 key, value = hint.split(
',', 1)
82 notification.set_hint_string(key, value)
84 for action
in args.action:
85 action_id, action_label = action.split(
',', 1)
86 notification.add_action(
93 def signal_handler(signam, frame):
96 signal.signal(signal.SIGINT, signal_handler)
98 loop = GLib.MainLoop.new(
None,
False)
99 notification.connect(
'closed', quit_callback)