#!/bin/sh -
#
#	$NetBSD: sensor_battery,v 1.8 2014/03/13 00:50:55 christos Exp $
#
# Generic script for battery sensors.
#
# Arguments passed by powerd(8):
#
#	script_path device event sensor state_description
#
case "${2}" in
normal)
	logger -p warning \
	    "${0}: (${3}) capacity reached normal state [${1}]" >&1
	exit 0
	;;
state-changed)
	logger -p warning "${0}: (${3}) state changed to ${4} [${1}]" >&1
	exit 0
	;;
warning-capacity|warning-under)
	logger -p warning \
	    "${0}: (${3}) capacity below warning limit [${1}]" >&1
	exit 0
	;;
critical-capacity|critical-under)
	logger -p warning \
	    "${0}: (${3}) capacity below critical limit [${1}]" >&1
	exit 0
	;;
warning-over)
	logger -p warning \
	    "${0}: (${3}) capacity above warning limit [${1}]" >&1
	exit 0
	;;
critical-over)
	logger -p warning \
	    "${0}: (${3}) capacity above critical limit [${1}]" >&1
	exit 0
	;;
high-capacity)
	logger -p warning \
	    "${0}: (${3}) capacity above high limit [${1}]" >&1
	exit 0
	;;
maximum-capacity)
	logger -p warning \
	    "${0}: (${3}) capacity above maximum limit [${1}]" >&1
	exit 0
	;;
#
# This event is _ONLY_ received when all AC Adapters are OFF and all
# batteries on the system are in CRITICAL or LOW state.
#
# It is not recommended to remove the shutdown call.
#
low-power)
	logger -p warning "${0}: LOW POWER! SHUTTING DOWN." >&1
	/sbin/shutdown -p now "${0}: LOW POWER! SHUTTING DOWN."
	exit 0
	;;
*)
	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
	exit 1
	;;
esac
