~macslow/unity-notifications/fix-1308011

« back to all changes in this revision

Viewing changes to examples/suppress-sound.py

Added the backend-part of sound-hint support with two additional examples demonstrating its use. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
################################################################################
 
4
##3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
 
5
##      10        20        30        40        50        60        70        80
 
6
##
 
7
## Info: 
 
8
##    Example of how to use libnotify correctly
 
9
##
 
10
## Run:
 
11
##    chmod +x suppress-sound.py
 
12
##    ./suppress-sound.py
 
13
##
 
14
## Copyright 2014 Canonical Ltd.
 
15
##
 
16
## Author:
 
17
##    Mirco "MacSlow" Mueller <mirco.mueller@canonical.com>
 
18
##
 
19
## This program is free software: you can redistribute it and/or modify it
 
20
## under the terms of the GNU General Public License version 3, as published
 
21
## by the Free Software Foundation.
 
22
##
 
23
## This program is distributed in the hope that it will be useful, but
 
24
## WITHOUT ANY WARRANTY; without even the implied warranties of
 
25
## MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
26
## PURPOSE.  See the GNU General Public License for more details.
 
27
##
 
28
## You should have received a copy of the GNU General Public License along
 
29
## with this program.  If not, see <http://www.gnu.org/licenses/>.
 
30
##
 
31
################################################################################
 
32
 
 
33
import os
 
34
import sys
 
35
import pynotify
 
36
import example
 
37
 
 
38
if __name__ == '__main__':
 
39
        if not pynotify.init ("suppress-sound"):
 
40
                sys.exit (1)
 
41
 
 
42
        # call this so we can savely use capabilities dictionary later
 
43
        example.initCaps ()
 
44
 
 
45
        # show what's supported
 
46
        example.printCaps ()
 
47
 
 
48
        # try suppress-sound support
 
49
        n = pynotify.Notification ("Lotsof N. Oise",
 
50
                                   "With the popping up of this notification, you should NOT hear a sound being played.",
 
51
                                   os.getcwd() + "/assets/avatar2.jpg")
 
52
        n.set_hint_string ("sound-file", "/usr/share/sounds/ubuntu/stereo/desktop-login.ogg")
 
53
        n.set_hint_string ("suppress-sound", "true")
 
54
        n.show ()