1#!/bin/sh - 2# 3# $NetBSD: sensor_battery,v 1.7 2010/02/15 22:56:13 pgoyette Exp $ 4# 5# Generic script for battery sensors. 6# 7# Arguments passed by powerd(8): 8# 9# script_path device event sensor state_description 10# 11case "${2}" in 12normal) 13 logger -p warning \ 14 "${0}: (${3}) capacity reached normal state [${1}]" >&1 15 exit 0 16 ;; 17state-changed) 18 logger -p warning "${0}: (${3}) state changed to ${4} [${1}]" >&1 19 exit 0 20 ;; 21warning-capacity) 22 logger -p warning \ 23 "${0}: (${3}) capacity below warning limit [${1}]" >&1 24 exit 0 25 ;; 26critical-capacity) 27 logger -p warning \ 28 "${0}: (${3}) capacity below critical limit [${1}]" >&1 29 exit 0 30 ;; 31high-capacity) 32 logger -p warning \ 33 "${0}: (${3}) capacity above high limit [${1}]" >&1 34 exit 0 35 ;; 36maximum-capacity) 37 logger -p warning \ 38 "${0}: (${3}) capacity above maximum limit [${1}]" >&1 39 exit 0 40 ;; 41# 42# This event is _ONLY_ received when all AC Adapters are OFF and all 43# batteries on the system are in CRITICAL or LOW state. 44# 45# It is not recommended to remove the shutdown call. 46# 47low-power) 48 logger -p warning "${0}: LOW POWER! SHUTTING DOWN." >&1 49 /sbin/shutdown -p now "${0}: LOW POWER! SHUTTING DOWN." 50 exit 0 51 ;; 52*) 53 logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 54 exit 1 55 ;; 56esac 57