On Linux Ubuntu PCs and servers, many laptops can check battery remaining capacity, and this article introduces how to check it.
Note that the Ubuntu version is 16.04. If the version is different, an error may occur, so please refer to the documentation in that case.
To check the battery, use upower -i /org/freedesktop/UPower/devices/battery_BAT0.
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "(state|time to empty|percentage)"
state: discharging
time to empty: 8.4 hours
percentage: 86%
Note that this command doesn’t seem to work on Ubuntu 18.04. I asked on ask.ubuntu but it seems no good. Or maybe it works but in some cases like mine it doesn’t work.
I’m still investigating how to do it on Ubuntu 18.04.