[Debian-eeepc-devel] Low battery and ugly shutdown problems

Jelle de Jong jelledejong at powercraft.nl
Tue Jun 3 14:11:28 UTC 2008


� wrote:
> Hello.
> 
> I'm running Linux EeeOS 2.6.24-1-686 on my 701 and found that 
> gnome-power-manager don't warn me when battery is low and my system runs 
> out of battery until it shuts down uncleanly making errors on my filesystem.
> 
> Probably there's some other power manager daemon that works well, but 
> I've written a stupid script that looks for remaining battery every 2 
> minutes warning me with an xmessage when battery is lower than 20% and 
> shutting down my machine cleanly when it reaches 10%.
> 
> Here it is:
> 
>     ##!/bin/sh
>     while true
>     do
>     if ! grep -q on-line /proc/acpi/ac_adapter/AC0/state ; then
>             BAT_DIR=/proc/acpi/battery/BAT0
>             FULL_BAT=`grep 'last full capacity' ${BAT_DIR}/info | awk '{
>     print $4 }'`
>             CUR_BAT=`grep 'remaining capacity' ${BAT_DIR}/state | awk '{
>     print $3 }'`
>             AVG=`expr $(expr ${CUR_BAT} \* 100) / ${FULL_BAT}`
> 
>             if [ "$AVG" -le "20" ]; then
>                 xmessage Warning, Low Battery... $AVG &
>             fi
>             if [ "$AVG" -le "10" ]; then
>                 xmessage I'll shut down in 2 minutes unless you connect
>     to AC. &
>                 sleep 120
>                 if ! grep -q on-line /proc/acpi/ac_adapter/AC0/state ; then
> 
>                     # YOU MAY CHANGE THIS ACCORDING TO YOUR DE.
>                     gdm-control --shutdown
>                     lxsession -exit
>                 fi
>             fi
>     fi
>     sleep 120
> 
>     done
> 
> 
> I just run it in background when my lxsession starts.
> 
> Hope to be helpfull and excuse my bad English.
> 

I use the below shell loop:

> while true
> do
> 	if grep -q Discharging /sys/class/power_supply/BAT0/status
> 	then
> 		if grep -q 1000 /sys/class/power_supply/BAT0/charge_now
> 		then
> 			xmessage "I'll shut down in 4 minutes unless you connect to AC" &
> 			sleep 240
> 			if ! grep -q Charging /sys/class/power_supply/BAT0/status
> 			then
> 				sudo shutdown -h now
> 			fi
> 		fi
> 	fi
> 	sleep 120
> done

Kind regards,

Jelle



More information about the Debian-eeepc-devel mailing list