Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Created February 20, 2012 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ajnasz/1869223 to your computer and use it in GitHub Desktop.
Save Ajnasz/1869223 to your computer and use it in GitHub Desktop.
#!/bin/sh
maxcapcity=$(awk '/design capacity:/ {print $3}' /proc/acpi/battery/BAT0/info);
remainingcapacity=$(awk '/remaining capacity:/ {print $3}' /proc/acpi/battery/BAT0/state);
chargingstate=$(awk '/charging state:/ {print $3}' /proc/acpi/battery/BAT0/state)
used=$(($maxcapcity - $remainingcapacity));
warnperc=0.1;
if [ "$chargingstate" = "charging" ];
then
exit 0;
fi
currentcapacity=`echo "$maxcapcity * $warnperc" | bc`
if [ `echo "$currentcapacity > $remainingcapacity" | bc` -gt 0 ];
then
echo "WARNING: BATTERY LOW" | DISPLAY=:0 aosd_cat -n "bitstream-vera-sans 22" -p 0 -x 20 -y 20 -u 10000 --fore-color=red
fi;
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment