2 from __future__
import print_function
24 from gi.repository
import GLib, Notify
28 def action_callback(notification, action_id, data):
32 def quit_callback(notification):
36 if __name__ ==
'__main__':
37 parser = argparse.ArgumentParser(
38 description=
'Create an interactive notification'
43 help=
'summary text of the notification',
48 help=
'body text of the notification',
53 help=
'path to the icon to display',
58 help=
'id and label for the callback in the format: id,label',
64 help=
'LOW, NORMAL, CRITICAL',
65 choices=[
'LOW',
'NORMAL',
'CRITICAL'],
70 help=
'list of comma sep options',
75 args = parser.parse_args()
77 Notify.init(
'Interactive Notifications')
79 notification = Notify.Notification.new(args.summary, args.body, args.icon)
81 for hint
in args.hints:
82 key, value = hint.split(
',', 1)
83 notification.set_hint_string(key, value)
85 for action
in args.action:
86 action_id, action_label = action.split(
',', 1)
87 notification.add_action(
94 def signal_handler(signam, frame):
97 signal.signal(signal.SIGINT, signal_handler)
99 loop = GLib.MainLoop.new(
None,
False)
100 notification.connect(
'closed', quit_callback)