Archive for November, 2010

KNotify Plugins (Or, “What I’ve been working on, now with details”)

I didn’t say much in my last post because I was still working things out.  Now I’m pleased to say that support for notification plugins has hit KNotify in KDE trunk as of last week.  The whole thing started when I was talking with some friends about an idea I’d been tossing around to forward notifications from my laptop/desktop to my N900 over the LAN, so that I wouldn’t miss important events when away frm the keyboard.  Aaron Seigo pointed out that the behaviour I wanted could be done nicely with KNotify, but that it currently required notification actions to be compiled in.  With a lot of help from him and others, I got going, and managed to get it done before the freeze.  I still have done no work towards my original idea, but I had some realizations while working on the code.  For one thing, notifications on the G15 keyboard’s auxiliary LCD are darn cool. :)   For another, it occurred to me that as KDE technologies move to the mobile world, and other non-traditional form-factors, there will be devices with blinky lights (OHAI, N900) , vibration motors, and who knows what other hardware that someone might want to utilize for notifications.  Now a vendor or developer can write a simple plugin and ship it for a specific device or use-case.

However… there is a caveat, and that is that there is currently no UI support for the extra plugins.  This means that for now you will have to enable plugins for each event individually by mucking around in configuration files.  I’ll be working on resolving this for 4.7.

If anyone wants to try writing plugins, it’s quite straightforward.  Start by taking a look at the example code here.

The important bits:

  • Derive from KNotifyPlugin, and link to libknotifyplugin
  • Implement the pure virtual KNotifyPlugin::optionName() method, and set it to return an identifying name for your plugin.  This is what will go in the “Action=” field in the config files
  • Implement KNotifyPlugin::notify(), and do whatever the heck you want to – it’s that simple.  If you want to make a robotic bunny jump up and down every time you receive an e-mail, do so – and send me a picture.
  • Make sure to include the macro at the bottom: e.g. K_EXPORT_KNOTIFY_METHOD(g15message, NotifyByG15Message), where “g15message” is the library name, and “NotifyByG15Message” is your plugin class name.
  • Once your plugin is installed, edit any fooapprc.notifyrc file in $kdeprefix/share/config, and add the name (as mentioned above) to the “Action=” field, optionally using |’s to separate multiple actions.

Comments appreciated, especially if you write any plugins.  Code is also appreciated at the Gitorious link above; the G15 plugin is rather rudimentary right now, for example, and could use some love.

Cheers!

P.S. If you like this, there’s a very lonely Flattr button sitting in the sidebar. *wink*

,

10 Comments

Follow

Get every new post delivered to your Inbox.