~jconti/recent-notifications/trunk

« back to all changes in this revision

Viewing changes to test-appname.py

  • Committer: Jason Conti
  • Date: 2011-02-12 23:44:24 UTC
  • Revision ID: jason.conti@gmail.com-20110212234424-frw0kjj1klqx2ncy
Adding an option to blacklist notifications based on app_name. Applications to be blacklisted should be listed in the file ~/.config/recent-notifications/blacklist, one app_name per line. The app_names are case-sensitive and are listed in the notifications as "from app_name" such as "from Gwibber" or "from Pidgin". They can also be found in ~/.cache/recent-notifications.log on the app_name lines. Thanks to Dinero Francis for reporting the issue.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import pygtk
 
2
pygtk.require("2.0")
 
3
import pynotify
 
4
import sys
 
5
 
 
6
def main():
 
7
  if len(sys.argv) < 2:
 
8
    print "usage: test-appname.py app_name"
 
9
    sys.exit(1)
 
10
 
 
11
  app_name = sys.argv[1]
 
12
 
 
13
  if not pynotify.init(sys.argv[1]):
 
14
    print "Failed to initialize notifications."
 
15
    sys.exit(1)
 
16
 
 
17
  n = pynotify.Notification("Message from " + app_name,
 
18
      "This is a test, this is only a test.")
 
19
 
 
20
  if not n.show():
 
21
    print "Failed to send notification."
 
22
    sys.exit(1)
 
23
 
 
24
if __name__ == "__main__":
 
25
  main()