This is one of the first developing fruits that developed under the guidance of the Project Timelord roadmap. But before I talk about Kubuntu Notification Helper, I should give a little history about its predecessor, Update Notifier KDE.
Update Notifier KDE
One and a half years ago when work on Kubuntu 8.10 started, we found ourselves in need of a new update notifier. The new Adept didn’t have one yet, and the old Adept was incompatible with KDE4 due to the lack of a Konsole KPart in our kdebase packages. (Now at KDE4) So Riddell whipped up a simple PyKDE KApplication that would spawn KSystemTrayIcons when updates were available, upgrade information was available, apport crash notifications were available, or reboot notifications were available.
In Kubuntu 9.04 Update Notifier KDE gained the abilities to notify the user of installable nonfree software such as the Flash plugin and MP3 codecs. In Kubuntu 9.10 update notification was taken over by KPackageKit, but since KPackageKit only covered software update notification, Update Notifier KDE was kept around to do everything else it does.
It is right about now that I would like to talk about the Achilles heel of Update Notifier KDE, its RAM usage. This was worse when it actually notified of software updates, easily taking up 32 MB of RAM while checking for updates. But even now in Kubuntu 9.10, by my somewhat-unscientific benchmarks using KSysGuard (why hello there, seli), Update Notifier KDE still uses 10 MB of unshared RAM while doing nothing, waiting for things to happen. I believe, mainly, that this is Python overhead, demonstrating that Python’s niche is definitely not notification daemons. 10 MB is always too much RAM taken to do nothing.
Kubuntu Notification Helper
It was for the following reasons that Harald and I decided to start a C++ KDE Daemon-based rewrite of Update Notifier KDE:
- C++ would be much better on RAM usage.
- The old python script was sorta getting a bit messy
- It didn’t actually do update notification anymore, and we had to change the name anyway.
Before I continue on, I would like to emphasize that this is not a certainty for Kubuntu 10.04. While Kubuntu Notification Helper does do what it does better than Update Notifier KDE, it is also new. If it cannot meet the functionality that Update Notifier KDE currently offers then it will not replace Update Notifier KDE for 10.04.
That being said, it already does quite a bit of what Update Notifier KDE currently does. At the moment it does:
- Apport crash report notification
- Upgrade hook notification (e.g. telling you to restart Firefox)
- Reboot notification
It currently lacks the following features that Update Notifier KDE currently has:
- Codec installation notification
- Distribution upgrade notification (e.g. 9.04 -> 9.10 upgrade notification)
As I mentioned before, Kubuntu Notification Helper is a KDED module written in C++. Initially I did a quick port of the reboot and apport notification from Update Notifier KDE, making a simple C++ KApplication-based notifier that notified with your standards Plasma KNotifications. This alone used 5x less RAM than the current python script, so I got excited and moved from a KApplication to a KDED module, which saved even more RAM usage. Now at idle it only uses 0.3 MB of RAM, and only uses 1-2 MB or so when displaying a notification. (Except upgrade hooks… will get to that later) At idle, this is around a 50x improvement from update-notifier-kde, and at least a 5x improvement while actually doing things.
Around this time, Harald Sitter (apachelogger) came around with the idea of making a centralized Event class on which to base each of our things we wanted to notify. Instead of being functions in a declarative-script-type class, each Event is only created when needed. I must say that his design is superb, and it made the code base cleaner, more consistent and more efficient. Harald could probably wax on about the implementation details better than I can, so I’ll leave that up to him.😉
So, screenshot time. First off I will tackle Apport notification:
Now, I’m not a big fan of apport’s crash handler. Dr. Konqi ftw. But Apport still has its uses, for example reporting bugs for package upgrade failures. Even though there’s a good chance Apport crash detection will be turned of in 10.04, apport will still be around for things like package upgrade failures. Anyway, the UI is fairly straightforward here. Clicking “details” will launch the apport dialog, and ignore will dismiss the notification. “never show again” will free you from apport notifications permanently if you so desire. The current plan for “Ignore forever” is probably to make a config module where you can manage the notifications you want K-N-H to give. Perhaps it will be made a sub-module of the Notifications module in System Settings.
Next comes the reboot notification:
Not much different than what we currently have. Clicking reboot will bring up the standard KDE dialog confirming that you really want to reboot. The Ignore buttons function as before. And yes, we will make the ignore texts consistent eventually.😉
Last is the upgrade hook notification:
It looks similar to the rest of the notifications. But we have to provide our own UI for presenting the notifications to the user, since there may be multiple notifications:
Here’s the second page, so that you can see it:
Mutliple hooks will show up paged as seen in the screenshots. The sidebar will go away (automagically thanks to KDE) when only one hook is available. This implementation is sub-optimal at best. Eventually it’d be nice to just make a KNotification for each upgrade hook. This is just the quickest way I could port the functionality over from Update Notifier KDE.
In fact, the whole hook parsing setup could use some love, as its somewhat inefficient and complicated. If there was a simple RFC822 parser in C++, I would gladly use it rather than my custom parser, which is quite RAM hungry. I should note that even though hook handling is RAM-hungry, it only uses 6 MB RAM, which still manages to only be 60% of what Update Notifier KDE uses at idle, which I find quite amusing. You don’t see upgrade hooks that often anyways, so it shouldn’t be a problem, especially since it is using the RAM to actually do something. Code first, optimize later, right? At the least it all works.
I sincerely hope we can implement codec and distribution upgrade notification in Kubuntu Notification Helper so that it can be included in 10.04. Less bloat is always good. If you know C++ (a bit of python knowledge wouldnt’ hurt) and would like to help us with this piece of software, feel free to jump in! You can find the code here, and all you need to do to get started is to do a bzr branch lp:kubuntu-notification-helper to check out the source.