11.1Sxtraeme#!/bin/sh -
21.1Sxtraeme#
31.8Schristos#	$NetBSD: sensor_battery,v 1.8 2014/03/13 00:50:55 christos Exp $
41.1Sxtraeme#
51.1Sxtraeme# Generic script for battery sensors.
61.1Sxtraeme#
71.1Sxtraeme# Arguments passed by powerd(8):
81.1Sxtraeme#
91.3Sxtraeme#	script_path device event sensor state_description
101.4Sxtraeme#
111.1Sxtraemecase "${2}" in
121.1Sxtraemenormal)
131.4Sxtraeme	logger -p warning \
141.4Sxtraeme	    "${0}: (${3}) capacity reached normal state [${1}]" >&1
151.1Sxtraeme	exit 0
161.1Sxtraeme	;;
171.3Sxtraemestate-changed)
181.3Sxtraeme	logger -p warning "${0}: (${3}) state changed to ${4} [${1}]" >&1
191.1Sxtraeme	exit 0
201.1Sxtraeme	;;
211.8Schristoswarning-capacity|warning-under)
221.4Sxtraeme	logger -p warning \
231.6Spgoyette	    "${0}: (${3}) capacity below warning limit [${1}]" >&1
241.6Spgoyette	exit 0
251.6Spgoyette	;;
261.8Schristoscritical-capacity|critical-under)
271.6Spgoyette	logger -p warning \
281.6Spgoyette	    "${0}: (${3}) capacity below critical limit [${1}]" >&1
291.4Sxtraeme	exit 0
301.4Sxtraeme	;;
311.8Schristoswarning-over)
321.8Schristos	logger -p warning \
331.8Schristos	    "${0}: (${3}) capacity above warning limit [${1}]" >&1
341.8Schristos	exit 0
351.8Schristos	;;
361.8Schristoscritical-over)
371.8Schristos	logger -p warning \
381.8Schristos	    "${0}: (${3}) capacity above critical limit [${1}]" >&1
391.8Schristos	exit 0
401.8Schristos	;;
411.7Spgoyettehigh-capacity)
421.7Spgoyette	logger -p warning \
431.7Spgoyette	    "${0}: (${3}) capacity above high limit [${1}]" >&1
441.7Spgoyette	exit 0
451.7Spgoyette	;;
461.7Spgoyettemaximum-capacity)
471.7Spgoyette	logger -p warning \
481.7Spgoyette	    "${0}: (${3}) capacity above maximum limit [${1}]" >&1
491.7Spgoyette	exit 0
501.7Spgoyette	;;
511.4Sxtraeme#
521.4Sxtraeme# This event is _ONLY_ received when all AC Adapters are OFF and all
531.4Sxtraeme# batteries on the system are in CRITICAL or LOW state.
541.4Sxtraeme#
551.4Sxtraeme# It is not recommended to remove the shutdown call.
561.4Sxtraeme#
571.4Sxtraemelow-power)
581.5Sxtraeme	logger -p warning "${0}: LOW POWER! SHUTTING DOWN." >&1
591.4Sxtraeme	/sbin/shutdown -p now "${0}: LOW POWER! SHUTTING DOWN."
601.1Sxtraeme	exit 0
611.1Sxtraeme	;;
621.1Sxtraeme*)
631.1Sxtraeme	logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1
641.1Sxtraeme	exit 1
651.1Sxtraeme	;;
661.1Sxtraemeesac
67