From owner-freebsd-acpi@FreeBSD.ORG Sat Nov 25 20:40:23 2006 Return-Path: X-Original-To: freebsd-acpi@freebsd.org Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9D70516A403 for ; Sat, 25 Nov 2006 20:40:23 +0000 (UTC) (envelope-from nate@root.org) Received: from root.org (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id AD98343D5D for ; Sat, 25 Nov 2006 20:39:33 +0000 (GMT) (envelope-from nate@root.org) Received: (qmail 88353 invoked from network); 25 Nov 2006 20:40:24 -0000 Received: from ppp-71-139-31-204.dsl.snfc21.pacbell.net (HELO ?10.0.5.59?) (nate-mail@71.139.31.204) by root.org with ESMTPA; 25 Nov 2006 20:40:24 -0000 Message-ID: <4568AA2F.4050602@root.org> Date: Sat, 25 Nov 2006 12:40:15 -0800 From: Nate Lawson User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: "M. Warner Losh" References: <20061124.201214.1656128345.imp@bsdimp.com> In-Reply-To: <20061124.201214.1656128345.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-acpi@freebsd.org Subject: Re: How do I... X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Nov 2006 20:40:23 -0000 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. -- Nate