Date: Sun, 26 Nov 2006 16:27:28 -0800 From: Nate Lawson <nate@root.org> To: "M. Warner Losh" <imp@bsdimp.com> Cc: freebsd-acpi@freebsd.org Subject: Re: How do I... Message-ID: <456A30F0.3030004@root.org> In-Reply-To: <20061125.160917.1628359610.imp@bsdimp.com> References: <20061124.201214.1656128345.imp@bsdimp.com> <4568AA2F.4050602@root.org> <20061125.160917.1628359610.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
M. Warner Losh wrote: > In message: <4568AA2F.4050602@root.org> > Nate Lawson <nate@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 You'd have to add that to the code that pulls the new battery value. It would compare it to the last % and send a notify if they're different. You could get rid of that printf then and just add a default devd rule for that. Note though that it the critical flag is determined by the BIOS. It could be 5% on one system, 10% on the next. You could add a user-configurable sysctl "critical" flag that was compared to the % and if <=, sets the ACPI_BATT_STAT_CRITICAL flag even though the BIOS didn't. The devd notify code would be the same in either case. The flag as set by the BIOS is level-triggered so it stays set until the battery is charged above the critical level (i.e. even on AC). You don't want to trigger devd notifies on the way back up to normal, although sending a different notify once it is !critical might be useful. Please send me a patch for review if you implement this. Thanks, -- Nate
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?456A30F0.3030004>