My thinkpad 470s has two batteries and all linux commands to return
battery capacity return capacity for each battery. I needed to update my awesomewm scripts
to return battery capacity across all available batteries. This was a good exercise of string manipulation with shell. I came up with two versions:
1
paste -d'+' /sys/class/power_supply/BAT*/capacity | sed 's/$/)\/2/g' | sed 's/^/(/g' | bc
1
/usr/bin/acpi -b | cut -d' ' -f4 | sed 's/%.*/\/2/g' | paste -s -d+ - | bc
And then I looked up at stack overflow and found a better solution: