This script was originaly for using acpi to get the values but should give you an idea on how to calculate what you need. Requires calc to be installed
#!/bin/bash
math() { calc -d "$@"|tr -d ~; }
cd /proc/acpi/battery/BAT0;
max=$(grep 'design capacity:' info|awk '{print $3}')
current=$(grep 'remaining capacity:' state|awk '{print $3}')
percent=$(math "($current / $max) * 100");
echo $(echo $percent|cut -d. -f1)%