15.04.2009 20:02

Laptop-mode-tools

These days my main workstation is a laptop so battery power is an important issue. There are many tweaks one can use on GNU/Linux to conserve it and most of them were joined in the laptop-mode-tools project ("lmt" later in the text). Basically it's just a shell script (that gets run on AC events) with a bunch of configuration files controlling its behavior. Let's talk results first, from initial 1:30h of battery power I went to 2:00 - 2:30h, good results considering that I have very modest hardware - a CPU that can't be scaled nor undervolted and a lousy battery from SANYO. My power consumption went from initial 21W to 16W when running on battery. Some people with better hardware and some smart tweaks can go as low as 9-10W extending their battery life much longer.

As I said lmt covers most of the tweaks, not all, and at first I had to patch it extensively to add support for my hardware and additional tweaks. But it gets better and better in every version as it adds more tweaks. These days I only need the patch to add support for rfkill on my Acer so I can completely shut down bluetooth.

One very important function is "auto hibernate on low battery", I often get absorbed in my work and loose track of remaining battery power, lost a few important documents that way. As I mentioned, I have a lousy battery which also lacks alarm support. At first lmt relied on ACPI events so I used this script. The alternative was to invoke lmt every few minutes from a cronjob, not so elegant when you are trying to minimize disk reads/writes. Recent version of lmt do support battery polling trough a module-helper which then again calls lmt every few minutes, so I have to patch that too.

Another interesting functionality is the "start-stop-programs" module which allows you to start/stop any service or process on AC events. I wrote about awesome window manager earlier and its widgets. Depending on what they do and how often and aggressive they do it, they could cause quite a few wake-ups. So I combined start-stop-programs module with wicked built-in suspend/resume functionality. The result is this script which is run on AC changes and automatically suspends/resumes widgets. Although awesome 3 and wicked are much better than awesome 2 and amazing were - powertop used to report them as the top cause of wake-ups while now they barely make the list of top 20.


Written by anrxc | Permalink | Filed under desktop, code