自娱自乐,旨在记录,以便日后查阅,高手请路过。
#!/bin/bash
FULL=`cat /proc/acpi/battery/BAT0/info | grep full | cut -c 26-30`
PRESENT=`cat /proc/acpi/battery/BAT0/state | grep remaining | cut -c 26-30`
# STATE=`expr $PRESENT / $FULL`
STATE=`echo "scale=2;$PRESENT / $FULL * 100" | bc | cut -d . -f 1`
AC=`cat /proc/acpi/ac_adapter/ADP1/state | cut -c 26-28`
if [ $STATE -le 7 -a $AC = off ]; then
wall "Full power of the battery is $FULL. Present power of the battery is $PRESENT. $STATE% power is remain... Please char ge..."
mpg123 /home/zeur/icons/batteryAlarm.mp3 &> /dev/null
mpg123 /home/zeur/icons/batteryAlarm.mp3 &> /dev/null
mpg123 /home/zeur/icons/batteryAlarm.mp3 &> /dev/null
mpg123 /home/zeur/icons/batteryAlarm.mp3 &> /dev/null
mpg123 /home/zeur/icons/batteryAlarm.mp3 &> /dev/null
sleep 10
/home/zeur/script/batteryAlarm.sh
fi
if [ $STATE -gt 7 -o $AC = 'on-' ]; then
sleep 60
/home/zeur/script/batteryAlarm.sh
fi
unset FULL PRESENT STATE