/usr/lib/python3/dist-packages/unity8/shell/create_interactive_notification.py is in unity8-autopilot 8.12+16.04.20160401-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | #!/usr/bin/env python3
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Unity Autopilot Test Suite
# Copyright (C) 2012, 2013, 2014, 2015 Canonical
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import argparse
from gi.repository import GLib, Notify
import signal
def action_callback(notification, action_id, data):
print(action_id)
def quit_callback(notification):
loop.quit()
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Create an interactive notification'
)
parser.add_argument(
'--summary',
help='summary text of the notification',
default='Summary'
)
parser.add_argument(
'--body',
help='body text of the notification',
default='Body'
)
parser.add_argument(
'--icon',
help='path to the icon to display',
default=None
)
parser.add_argument(
'--action',
help='id and label for the callback in the format: id,label',
action='append',
default=[]
)
parser.add_argument(
'--urgency',
help='LOW, NORMAL, CRITICAL',
choices=['LOW', 'NORMAL', 'CRITICAL'],
default='NORMAL'
)
parser.add_argument(
'--hints',
help='list of comma sep options',
action='append',
default=[]
)
args = parser.parse_args()
Notify.init('Interactive Notifications')
notification = Notify.Notification.new(args.summary, args.body, args.icon)
for hint in args.hints:
key, value = hint.split(',', 1)
notification.set_hint_string(key, value)
for action in args.action:
action_id, action_label = action.split(',', 1)
notification.add_action(
action_id,
action_label,
action_callback,
None
)
def signal_handler(signam, frame):
loop.quit()
signal.signal(signal.SIGINT, signal_handler)
loop = GLib.MainLoop.new(None, False)
notification.connect('closed', quit_callback)
notification.show()
loop.run()
|