Note that the "let" command in bash lets you avoid the need for bc. And here's how to make a function out of the code, so it is a bit more efficient, and is easy to run on even a chromebook. :)
function battery_level {
charge_current="$(cat /sys/class/power_supply/BAT0/charge_now)"
charge_full="$(cat /sys/class/power_supply/BAT0/charge_full)"
let "current=100*$charge_current/$charge_full"
echo "$current%"
}
Note that the "let" command in bash lets you avoid the need for
bc
. And here's how to make a function out of the code, so it is a bit more efficient, and is easy to run on even a chromebook. :)Thanks for the tip. I had no idea you could do arithmetic using
let
.