Get battery information via the terminal

--

In your /sys directory, you can get the status and capacity (percentage of power left) of your device’s battery.

For the status:

$ cat /sys/class/power_supply/BAT0/status

  • Unknown
  • Discharging
  • Charging
  • Full

For the capacity (percentage of power left in the battery):

$ cat /sys/class/power_supply/BAT0/capacity

This gives you a number.

You might have more than one battery on your device. You can find the list by doing this:

$ ls -l /sys/class/power_supply/ | grep -i bat

FYI the output is of symlinks.

--

--

No responses yet