#!/bin/bash # Copyright (C) 2011, 2013 Luke Shumaker if [[ $# -ne 2 ]]; then echo "Usage: $0 THRESHOLD COMMAND" fi thresh=$1 cmd=$2 while true; do num=`acpi -t|sed -nr 's/.*, ([0-9.]*) .*/\1/p` num=${num:-0} if (( "$num" > "$thresh" )); then eval "$cmd" else sleep 1 fi done