3
################################################################################
4
##3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
5
## 10 20 30 40 50 60 70 80
8
## Example of how to use libnotify correctly and at the same time comply to
9
## the new jaunty notification spec (read: visual guidelines)
12
## chmod +x low-urgency.py
15
## Copyright 2009 Canonical Ltd.
18
## Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
20
## This program is free software: you can redistribute it and/or modify it
21
## under the terms of the GNU General Public License version 3, as published
22
## by the Free Software Foundation.
24
## This program is distributed in the hope that it will be useful, but
25
## WITHOUT ANY WARRANTY; without even the implied warranties of
26
## MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
27
## PURPOSE. See the GNU General Public License for more details.
29
## You should have received a copy of the GNU General Public License along
30
## with this program. If not, see <http://www.gnu.org/licenses/>.
32
################################################################################
37
# even in Python this is globally nasty :), do something nicer in your own code
38
capabilities = {'actions': False,
40
'body-hyperlinks': False,
46
'image/svg+xml': False,
47
'x-canonical-private-synchronous': False,
48
'x-canonical-append': False,
49
'x-canonical-private-icon-only': False,
50
'x-canonical-truncation': False}
53
caps = pynotify.get_server_caps ()
55
print "Failed to receive server caps."
59
capabilities[cap] = True
62
info = pynotify.get_server_info ()
63
print "Name: " + info["name"]
64
print "Vendor: " + info["vendor"]
65
print "Version: " + info["version"]
66
print "Spec. Version: " + info["spec-version"]
68
caps = pynotify.get_server_caps ()
70
print "Failed to receive server caps."
73
print "Supported capabilities/hints:"
74
if capabilities['actions']:
76
if capabilities['body']:
78
if capabilities['body-hyperlinks']:
79
print "\tbody-hyperlinks"
80
if capabilities['body-images']:
82
if capabilities['body-markup']:
84
if capabilities['icon-multi']:
86
if capabilities['icon-static']:
88
if capabilities['sound']:
90
if capabilities['image/svg+xml']:
91
print "\timage/svg+xml"
92
if capabilities['x-canonical-private-synchronous']:
93
print "\tx-canonical-private-synchronous"
94
if capabilities['x-canonical-append']:
95
print "\tx-canonical-append"
96
if capabilities['x-canonical-private-icon-only']:
97
print "\tx-canonical-private-icon-only"
98
if capabilities['x-canonical-truncation']:
99
print "\tx-canonical-truncation"
102
if info["name"] == "notify-osd":
103
print "\tx- and y-coordinates hints are ignored"
104
print "\texpire-timeout is ignored"
105
print "\tbody-markup is accepted but filtered"
109
if __name__ == '__main__':
110
if not pynotify.init ("low-urgency"):
113
# call this so we can savely use capabilities dictionary later
116
# show what's supported
119
# try the icon-summary-body case
120
n = pynotify.Notification ("Gerhard Gepard",
121
"No, I'd rather see paint dry, pal *yawn*",
122
"notification-message-im")
123
n.set_urgency (pynotify.URGENCY_LOW)