Home | History | Annotate | Line # | Download | only in scripts
sensor_battery revision 1.6
      1 #!/bin/sh -
      2 #
      3 #	$NetBSD: sensor_battery,v 1.6 2009/06/13 15:35:10 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 #
     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 warning-capacity)
     22 	logger -p warning \
     23 	    "${0}: (${3}) capacity below warning limit [${1}]" >&1
     24 	exit 0
     25 	;;
     26 critical-capacity)
     27 	logger -p warning \
     28 	    "${0}: (${3}) capacity below critical limit [${1}]" >&1
     29 	exit 0
     30 	;;
     31 #
     32 # This event is _ONLY_ received when all AC Adapters are OFF and all
     33 # batteries on the system are in CRITICAL or LOW state.
     34 #
     35 # It is not recommended to remove the shutdown call.
     36 #
     37 low-power)
     38 	logger -p warning "${0}: LOW POWER! SHUTTING DOWN." >&1
     39 	/sbin/shutdown -p now "${0}: LOW POWER! SHUTTING DOWN."
     40 	exit 0
     41 	;;
     42 *)
     43 	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
     44 	exit 1
     45 	;;
     46 esac
     47