3
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
5
# Unity Autopilot Test Suite
6
# Copyright (C) 2012-2013 Canonical
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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(
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)