Date: Tue, 23 Aug 2005 08:18:40 +0200 From: m.ehinger@ltur.de To: Nate Lawson <nate@root.org> Cc: freebsd-acpi@freebsd.org Subject: Re: battery low script Message-ID: <OF85347732.1EA6F9F7-ONC1257066.00228516-C1257066.0022B833@gateway-inter.net> In-Reply-To: <430A02A4.1030303@root.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Sorry my mistake, i forgot it completely, thanks
(See attached file: battery)
maik
Nate Lawson <nate@root.org>
22.08.2005 18:51 An
m.ehinger@ltur.de
Kopie
Thema
Re: battery low script
m.ehinger@ltur.de wrote:
> Hi,
>
> i use the attached script to shutdown my notebook on low battery automatically.
>
> I also added the following to /etc/devd.conf
>
> notify 10 {
> match "system" "ACPI";
> match "subsystem" "CMBAT";
> action "/etc/battery $notify";
> };
>
>
> Please feel free to try without any guarantees.
>
> Comments are welcome.
>
> thanks
>
> Maik
the attachment was missing. Try sending it inline, not as an attachment.
--
Nate
[-- Attachment #2 --]
#!/bin/sh
#
# Copyright (C) 2005 Maik Ehinger <m.ehinger@ltur.de>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
state=$(sysctl -n hw.acpi.battery.state)
life=$(sysctl -n hw.acpi.battery.life)
# for debugging purpose
logger -t battery "state changed to $state $life $1"
case $state in
1)
# discharging ?
# i get no critical warnings so i test if life is below 5%
# gives me 8-10 min
if [ $life -lt 5 ]; then
logger -t battery "Emergency shutdown in 2 minutes. Life: $life $1"
# shutdown in 2 minutes if battery life is below 5%
# check if shutdown already running
if [ ! -e /var/run/nologin ]; then
/sbin/shutdown -p +2 "Battery low"
#
sleep 1
fi
fi
;;
2)
# kill shutdown on recharge
# only if shutdown is running
if [ -e /var/run/nologin ]; then
logger -t battery "shutdown canceled because of recharge. $life $1"
/usr/bin/killall shutdown
fi
;;
esac
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OF85347732.1EA6F9F7-ONC1257066.00228516-C1257066.0022B833>
