Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

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

share|improve this question
    
possible duplicate of How to check battery status using terminal? –  Ringtail Nov 24 '12 at 20:57

4 Answers 4

up vote 4 down vote accepted

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 if 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
share|improve this answer
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.

share|improve this answer
    
Good answer, thank you. Using cat /proc/acpi/battery/*/state as my battery is named BAT1 and I don't see many people having another battery present. –  Todd Partridge 'Gen2ly' Dec 22 '11 at 6:10

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

share|improve this answer

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

http://paste.mitechie.com/show/221/

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:

http://paste.mitechie.com/show/222/

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.