Ignore:
Timestamp:
Dec 9, 2010, 8:25:47 PM (14 years ago)
Author:
joergs
Message:

cleanup, added comments, get list of events

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kde/dbus/knotify-client

    • Property svn:keywords set to Id
    r938 r940  
    22# -*- coding: utf-8 -*-
    33
     4"""
     5knotify-client sends messages to the KDE knotify daemon.
     6KDE applications can define different types of messages
     7and theses types define different actions
     8(display message, play sound, start program, ...)
     9
     10tested on KDE 4.3.5 (openSUSE 11.2)
     11"""
     12
     13# $Id$
     14
     15
    416import sys
    517import dbus
     18from os import system
    619from pprint import pprint
    720from time import sleep
     
    1124from optparse import OptionParser
    1225
    13 parser = OptionParser()
     26
     27parser = OptionParser(usage = "\n  %prog [options] 'text message to send to knotify'\n  %prog --appevents APPLICATION")
    1428#parser.add_argument('message', type=string, nargs='+',
    1529#                   help='message text to send')
    1630parser.add_option('--event', dest='event', default="notification",
    17                    help='event')
    18 parser.add_option('--app', dest='app', default="kde",
    19                    help='fromApp')
     31                   help='event (default: %default). Use --appevents to get list of events')
     32parser.add_option('--app', dest='application', default="kde",
     33                   help='event from application (default: %default)')
    2034parser.add_option('--title', dest='title', default=sys.argv[0],
    21                    help='event')
     35                   help='text in title of knotify message')
    2236parser.add_option('--timeout', dest='timeout', type=int, default=0,
    2337                   help='timeout in seconds. Without timeout, message will stay until it is confirmed, but ' + sys.argv[0] + ' will return immedialy')
     38parser.add_option('--appevents', metavar='APPLICATION', dest='appevents',
     39                   help='print list of events for application')
    2440(options, args) = parser.parse_args()
    2541
    2642print "options:"
    2743pprint(options)
     44
     45if options.appevents:
     46    ressource = options.appevents + "/" + options.appevents + ".notifyrc"
     47    system("kread-ressource.py --type data " + ressource )
     48    exit(0)
    2849
    2950message = " ".join( args )
     
    5374# specifiing timeout as parameter does not show a effect,
    5475# therefore notification is closed manually after timeout
    55 id = knotify.event( options.event, options.app, [], options.title, message, [], [], options.timeout, dbus_interface="org.kde.KNotify")
     76id = knotify.event( options.event, options.application, [], options.title, message, [], [], options.timeout, dbus_interface="org.kde.KNotify")
    5677
    5778if options.timeout > 0:
Note: See TracChangeset for help on using the changeset viewer.