2 # Polls the battery status once per minute. Echos the status to ratpoison if the
3 # battery is discharging. At low battery status, it warns at 30,20 and 15 minutes
4 # remaining. Shutsdown at 9 minutes remaining. Requires 'acpitool' to poll the battery.
7 if [ $(acpitool | awk '/AC adapter/{print $4}') = "off-line" ]; then
8 bat_stat="$(acpitool | grep Battery)"
9 seconds_remaining=$(echo $bat_stat | awk '{print $6}' | awk -F':' '{print $1*3600 + $2*60 + $3}')
10 if [ $seconds_remaining -le 840 ]; then
12 elif [ $seconds_remaining -le 900 ]; then
13 ratpoison -c "echo Critical! 15 minutes of battery remaining. Shutting down in 1minute."
14 elif [ $seconds_remaining -le 1200 ]; then
15 ratpoison -c "echo Warning! 20 minutes of battery remaining. Shuttind down in 5 minutes."
16 elif [ $seconds_remaining -le 1800 ]; then
17 ratpoison -c "echo Warning, 30 minutes of battery remaining. Shutting down in 15 minutes."
19 ratpoison -c "echo $bat_stat"