[Sugar-devel] announce: alternate power management

pgf at laptop.org pgf at laptop.org
Fri Mar 13 17:33:00 EDT 2009


hi --

i had an itch that needed scratching, and the result is a
reimplementation of much (but not all) of what ohmd does
currently.

i've thought for some time (and i believe cjb agrees) that ohmd
is needlessly difficult to maintain and modify for our purposes
on the XO.  small improvements are difficult to implement
quickly.

since my heart is with more quasi-embedded systems than the XO's
current incarnation, part of my goal was to do a rewrite which
was not dependent on hald, dbus, or X11 -- power management
should work well from a console screen, and be available even if
none of those services is running.

i call the service i wrote "powerd".  it gets user idle/active
reports from the olpc-kbdshim daemon (which is watching all
user keypress and touchpad activity in any case), and it gets
reports regarding the hardware inputs (power button, lid and
ebook switches, ac adapter status, battery level, etc) either
from another small daemon that monitors /dev/input/event{0,1,2},
or from /sys nodes directly.

it basically recreates ohmd's "dim after a bit, then sleep"
behavior, with some additions:

  - a power button splash screen:  a second press of the power
     button invokes shutdown, simply waiting for a brief timeout
     invokes suspend, and any user activity cancels.  (i even
     managed to kinda sorta convey all that with graphics.  i'm
     sure every UI person that sees it will roll their eyes.)

  - configurable timeouts for screen dim and sleep.  the dim
    level is configurable.

  - different power management behavior when on wall power vs. 
    battery -- many laptop owners don't need to be miserly with
    power when running from an external source.  powerd makes
    this behavior selectable.

  - different power behavior when in ebook mode (though detection
    may be unreliable -- i think the ebook switch suffers from
    some issues we previously noticed with the lid switch).  this
    should let you configure things like a very short timeout until
    idle-suspend, and/or no screen dimming, when in ebook mode.  (i
    find the frequent on/off nature of the backlight when reading
    in ebook mode to be a distraction.)

  - clean shutdown on critically low battery.  (currently set at
    a reported 5%, at which point my laptop would only run for
    another couple of minutes.)

  - the ability to run arbitrary scripts after a resume.  (perhaps
    to reinit usb devices that don't suspend/resume properly?  haven't
    used this much yet.)

  - ease of customization, given that it's written in everyone's
    favorite interpreted language.

 unimplemented:

  - inhibiting idle suspend based on system or network load. 
    i.e., the system will dim or suspend when watching a video. 
    (there are hooks in place where these features should be
    implemented -- they're just not coded at all.)  there's
    no /etc/ohmd directory, so it honors /var/run/inhibit-idle-suspend
    instead.

  - no special support for the wireless mesh, whatsoever.  i
    couldn't remember how it was supposed to work, and i recall
    cjb saying it's hard to figure out whether the mesh is active
    or not.

  - there's some support for wake-on-wlan, but it's not well tested.

  finally a big one:
  - proper support for USB keyboards and mice.  i recently
    realized that since olpc-kbdshim only monitors the built-in
    keyboard and touchpad, powerd will think the user is idle
    while they type on a USB keyboard, and cheerfully suspend
    regardless.  (in my case, most of the time i want to
    auto-suspend is when i'm running on battery, and not using
    external devices, so i sort of forgot about this case.)

anyway, code is available here:
    http://dev.laptop.org/git/users/pgf/powerd/
and rpms are here:
    http://dev.laptop.org/~pgf/rpms/

you'll need to install both olpc-kbdshim and olpc-powerd (in that
order).  when installed, olpc-powerd disables ohmd, and reenables
it when uninstalled.  (so it's relatively safe to try.)

there's no gui or other convenience for configuration --
see/etc/powerd/powerd.conf.  the installed defaults should be
reasonable.  and you'll need to run:
    echo reconfig >/var/run/powerevents
after making changes to the config file.

paul
=---------------------
 paul fox, pgf at laptop.org


More information about the Sugar-devel mailing list