Changeset 938
- Timestamp:
- Dec 8, 2010, 4:08:14 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kde/dbus/knotify-client
r936 r938 4 4 import sys 5 5 import dbus 6 import pprint 6 from pprint import pprint 7 from time import sleep 7 8 8 try: 9 message = sys.argv[1] 10 except: 11 message = sys.argv[0] 9 # since python 2.7 10 #import argparse 11 from optparse import OptionParser 12 13 parser = OptionParser() 14 #parser.add_argument('message', type=string, nargs='+', 15 # help='message text to send') 16 parser.add_option('--event', dest='event', default="notification", 17 help='event') 18 parser.add_option('--app', dest='app', default="kde", 19 help='fromApp') 20 parser.add_option('--title', dest='title', default=sys.argv[0], 21 help='event') 22 parser.add_option('--timeout', dest='timeout', type=int, default=0, 23 help='timeout in seconds. Without timeout, message will stay until it is confirmed, but ' + sys.argv[0] + ' will return immedialy') 24 (options, args) = parser.parse_args() 25 26 print "options:" 27 pprint(options) 28 29 message = " ".join( args ) 30 31 print "message: ", message 12 32 13 33 knotify = dbus.SessionBus().get_object("org.kde.knotify", "/Notify") 34 35 36 # predefined notify settings, see 37 # find /usr/share/kde4/apps -name *.notifyrc 38 # grep -v '[a-z]\[' /usr/share/kde4/apps/kde/kde.notifyrc 14 39 15 40 # interface for knotify, … … 18 43 # const QString &event, 19 44 # const QString &fromApp, 20 # const QVariantList& contexts 45 # const QVariantList& contexts, 21 46 # const QString &title, 22 47 # const QString &text, … … 26 51 # qlonglong winId ); 27 52 53 # specifiing timeout as parameter does not show a effect, 54 # 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") 28 56 29 # predefined notify settings, see 30 # find /usr/share/kde4/apps -name *.notifyrc 31 # grep -v '[a-z]\[' /usr/share/kde4/apps/kde/kde.notifyrc 57 if options.timeout > 0: 58 print "Knotify-ID: ", id 32 59 33 #i = knotify.event( "warning", "mettenmeier_batteriemanagement", [], "Batteriemanagement", m, [0,0,0,0], [], 0, dbus_interface="org.kde.KNotify")60 sleep(options.timeout) 34 61 35 # use notify settings from powerdevil 36 #i = knotify.event( "criticalbattery", "powerdevil", [], "Batteriemanagement", m, [], [], 0, dbus_interface="org.kde.KNotify") 37 i = knotify.event( "notification", "kde", [], "knotify-client", message, [], [], 5, dbus_interface="org.kde.KNotify") 38 #pprint.pprint(i) 39 print i 62 # void update(int id, const QString &title, const QString &text, const KNotifyImage& image, const QStringList& actions); 63 #knotify.update( id, "knotify-client", "finished", [], [], dbus_interface="org.kde.KNotify") 64 65 #sleep( 1 ) 66 67 #for i in range(3): 68 #print i 69 #knotify.update( id, "knotify-client", str(i), [], [], dbus_interface="org.kde.KNotify") 70 ## void reemit(int id, const ContextList& contexts); 71 #knotify.reemit( id, [], dbus_interface="org.kde.KNotify" ) 72 #sleep(3) 73 74 knotify.closeNotification(id, dbus_interface="org.kde.KNotify"); 75 76 exit(0)
Note:
See TracChangeset
for help on using the changeset viewer.