5

Sometimes the energy status applet on my gnome panel suddenly disappears.

Is there a simple command to print the loading state of the battery?

Zanna
  • 70,465
NES
  • 33,195

4 Answers4

4
cat /proc/acpi/battery/BAT0/state

Will give you the remaining capacity.

cat /proc/acpi/battery/BAT0/info

To check the maximum capacity, both last and designed.

Note that BAT0 is a name that can change between computer models.

Javier Rivera
  • 35,153
4

There are different methods for this:
First, you could install the package acpi Install acpi and run it like to:

acpi -b

It will show you the battery's current capacity and whether it's charging, discharging and how long it will last/take to be recharged if charging.

If you don't want to install new packages, there's also the proc filesystem to query: cat /proc/acpi/battery/BAT0/state, which will give you the following output:

present:                 yes
capacity state:          ok
charging state:          charged
present rate:            1 mA
remaining capacity:      7800 mAh
present voltage:         12062 mV

for more details on your battery, check cat /proc/acpi/battery/BAT0/info

present:                 yes
design capacity:         7800 mAh
last full capacity:      2898 mAh
battery technology:      rechargeable
design voltage:          11100 mV
design capacity warning: 780 mAh
design capacity low:     236 mAh
cycle count:          0
capacity granularity 1:  78 mAh
capacity granularity 2:  78 mAh
model number:            DELL WK3798
serial number:           1226
battery type:            LION
OEM info:                Sanyo
Zanna
  • 70,465
1

You could execute gnome-power-statistics just to see in the gui and help you with the panel problem (Just to add to the help). The correct answer would be:

  1. Go to console and cd /proc/acpi/battery
  2. Type ls to see what is the name of your Battery, could be BAT0, BAT1, etc..
  3. If it is for example BAT0 Type cat BAT0/state
  4. If you need extra info type cat BAT0/info

You can also install acpi sudo apt-get install acpi

then type acpi -b in console

Luis Alvarado
  • 211,503
0

It's pretty easy to write a script to check the battery level stuff.
When I was toying with ruby I wrote one here

It does require the gem for ansi/code for the coloring at the terminal.

This is kind of a bash alternative that I used at one time

The stuff with the BAT0 vs BAT1 is that on my laptop I had a second battery in the DVD drive bay so there were actually two to check.

Zanna
  • 70,465
Rick
  • 3,647