Sometime last month I found myself looking for a KDE4 power manager. To be more specific, I was looking for a KDE4 port of KPowersave, but didn't find any. So I took it upon myself to port KPowersave to KDE4 and Solid only to conclude that it would be much easier to write a Solid based power manager from scratch. When looking for Solid documentation, I stumbled upon solidshell which I previously had no clue existed. Later that day I had written a simple power management application that could change brightness. When I had free time a few weeks ago I decided I'd upload my little app to playground, only to discover that 1) there was already a kde4powersave plasmoid and 2) there was a kded daemon based on the plasmoid. :-/
Anyway, it seems like a waste to stop working on it completely so I'll share my progress with you. First, I cloned the tooltip from guidance power manager.
Then I created something similar to the detailed dialog from KPowersave.
As well as the context menu structure of KPowersave.
But almost everything is powered by Solid and thus works similarly to solid-shell. However, I fixed the brightness controls to work on my system. KPowersave only set the brightness of the first laptop panel it received, solid-shell sets the brightness of every brightness control. On some systems such as my system that will result in conflicting brightness settings.
One thing I didn't like about previous power managers was that they polled to check system activity. The power manager is supposed to be an application that helps _conserve_ battery power but instead previous implementations may have served to further _drain_ battery power by unnecessary polling. In designing the system activity checking system for Lithium, I looked for solutions that would limit the need for polling. Lithium checks for system activity based on the smallest period that needs the system idle time.
For example, autodim is enabled and the timeout period set for autodim is 3 mins. A timer will start once Lithium is started and if after 3 minutes, the system is still active (i.e. idle time is 0), the timer will restart for another 3 minutes. This means that at worst polling will occur every 3 minutes for a system that is under continuous use. If after 3 minutes, the system has only been idle for 1.5 minutes, the timer will restart for 1.5 minutes.
To perform the opposite task of checking if the system is resuming from an idle state, previous power managers again polled the system. Lithium uses an ingenious solution adopted from the kde4powersave plasmoid which in turn borrowed it from ksnapshot. An offscreen widget grabs mouse and keyboard support and if it detects activity, it releases control and the system performs the necessary actions (restore brightness, etc.).
Working on a power manager brought to my attention that HAL doesn't necessarily correctly set the maximum speed of the processor. I also could not find a means to get the current CPU frequency from HAL. I ended up reading the information from /sys/devices/system/cpu which isn't ideal.
There are several more features I need to add such as an OSD and KMilo like functionality, better scheme support and config dialogs. I'll get to them sooner or later. It'll also be great to integrate my work with the kded daemon and the plasmoid but one reason I wrote an application that lived in the systray was to be able to use Lithium in other desktop environments.
So for my next little project, I will address another minor annoyance. I'm quite sick of people complaining about the lack of a KDE4 knetworkmanager so if no one else does so by Friday next week I'll begin work on a system tray icon port of knetworkmanager to KDE4. Or I could help out with the plasmoid... If someone's already working on it, please tell me so we don't duplicate any efforts. I've got a lot of other interesting projects that are begging for my attention. :)