1#!/bin/sh - 2# 3# $NetBSD: sensor_battery,v 1.8 2014/03/13 00:50:55 christos 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|warning-under) 22 logger -p warning \ 23 "${0}: (${3}) capacity below warning limit [${1}]" >&1 24 exit 0 25 ;; 26critical-capacity|critical-under) 27 logger -p warning \ 28 "${0}: (${3}) capacity below critical limit [${1}]" >&1 29 exit 0 30 ;; 31warning-over) 32 logger -p warning \ 33 "${0}: (${3}) capacity above warning limit [${1}]" >&1 34 exit 0 35 ;; 36critical-over) 37 logger -p warning \ 38 "${0}: (${3}) capacity above critical limit [${1}]" >&1 39 exit 0 40 ;; 41high-capacity) 42 logger -p warning \ 43 "${0}: (${3}) capacity above high limit [${1}]" >&1 44 exit 0 45 ;; 46maximum-capacity) 47 logger -p warning \ 48 "${0}: (${3}) capacity above maximum limit [${1}]" >&1 49 exit 0 50 ;; 51# 52# This event is _ONLY_ received when all AC Adapters are OFF and all 53# batteries on the system are in CRITICAL or LOW state. 54# 55# It is not recommended to remove the shutdown call. 56# 57low-power) 58 logger -p warning "${0}: LOW POWER! SHUTTING DOWN." >&1 59 /sbin/shutdown -p now "${0}: LOW POWER! SHUTTING DOWN." 60 exit 0 61 ;; 62*) 63 logger -p warning "${0}: unsupported event ${2} on device ${1}" >&1 64 exit 1 65 ;; 66esac 67