sensor_battery revision 1.5 1 #!/bin/sh -
2 #
3 # $NetBSD: sensor_battery,v 1.5 2007/10/11 19:47:26 xtraeme 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 #
11 case "${2}" in
12 normal)
13 logger -p warning \
14 "${0}: (${3}) capacity reached normal state [${1}]" >&1
15 exit 0
16 ;;
17 state-changed)
18 logger -p warning "${0}: (${3}) state changed to ${4} [${1}]" >&1
19 exit 0
20 ;;
21 user-capacity)
22 logger -p warning \
23 "${0}: (${3}) user defined capacity dropped below limit [${1}]" >&1
24 exit 0
25 ;;
26 #
27 # This event is _ONLY_ received when all AC Adapters are OFF and all
28 # batteries on the system are in CRITICAL or LOW state.
29 #
30 # It is not recommended to remove the shutdown call.
31 #
32 low-power)
33 logger -p warning "${0}: LOW POWER! SHUTTING DOWN." >&1
34 /sbin/shutdown -p now "${0}: LOW POWER! SHUTTING DOWN."
35 exit 0
36 ;;
37 *)
38 logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
39 exit 1
40 ;;
41 esac
42