April 26, 2010
KNotify Popups via Python
Source: http://www.documentroot.net/en/linux/knotify-python
Ocassionally one wants to give a script or program the opportunity to inform the user of some events – even if it is running hidden or in the background. For these cases KDE uses KNotify (a notification area in the systray). Since D-Bus has replaced DCOP, accessing KNotify has become more difficult. A small python script helps to do the job.
Enough talk, here’s the source code: (knotify.py)
1 2 3 4 5 6 7 | #!/usr/bin/python import sys, dbus knotify = dbus.SessionBus().get_object("org.kde.knotify", "/Notify") try: title, text = sys.argv[1:3] except: print 'Usage: knotify.py title text'; sys.exit(1) knotify.event("warning", "kde", [], title, text, [], [], 0, 0,\ dbus_interface="org.kde.KNotify") |

A direct qdbus-call does not seem to be possible since the called method expects a QVariantList as argument, which cannot be provided using the bash. That’s why i had to write the python script.
| Linux | bash, console, dbus, kde, knotify, python, qdbus, script, shell |
Doesn’t work for me :(
KDE 4.5.3