How do I...

M. Warner Losh imp at bsdimp.com
Sat Nov 25 15:08:54 PST 2006


In message: <4568AA2F.4050602 at root.org>
            Nate Lawson <nate at root.org> writes:
: M. Warner Losh wrote:
: > ... run a command when there's < 1% battery life left?
: > 
: > Warner
: 
: You add support here in acpi_cmbat.c:
:      /* XXX If all batteries are critical, perhaps we should suspend. */
:      if (sc->bst.state & ACPI_BATT_STAT_CRITICAL) {
:      	if ((sc->flags & ACPI_BATT_STAT_CRITICAL) == 0) {
: 	    sc->flags |= ACPI_BATT_STAT_CRITICAL;
: 	    device_printf(dev, "critically low charge!\n");
: 	}
:      }
: 
: Use the acpi_NotifyMumble function to send a value to devd.  You 
: probably want to make sure you're off AC power also since you may still 
: have that crit state when plugged in.  So read the value of AC status 
: (see kern_power.c for how to do this) before sending the notify.

I was thinking of sending the critical message as well as for each %
of battery life that changed.  I just wanted to make sure that it
wasn't being done already and i was captain clueless.

Warner


More information about the freebsd-acpi mailing list