-   Linux - Laptop and Netbook (
-   -   Remaining Battery Energy/Lifetime Detection (

Siva4Linux 10-26-2006 08:26 AM

Remaining Battery Energy/Lifetime Detection
Hello there,

I am wondering whether there exists any way for me to periodically estimate the remaining battery energy level of a notebook running FC 5. Let me put it in a different way. Suppose that a notebook is disconnected from the main
power supply and hence it relies on its remaining battery energy for its operation. For my protocol to work, it needs to periodically check the power level, and if a notebook has sufficient energy only, it can be used. Having explained the requirement, my question now is how to access/grab such
low-level information under Fedora Core 5.

Thanks in advance for taking your invaluable time to answer my question.


Dr. Siva Sivavakeesar

Lenard 10-26-2006 09:25 AM

Have a look at the cat /proc/acpi/battery/BATX/state[and info] files where X can be 0 or better.

Siva4Linux 10-27-2006 04:00 AM

Thanks for your information. Do you think getting the information through HAL is efficient ?

Siva4Linux 12-19-2006 04:23 AM

Dear All,

I have been trying to let my Routing protocol that runs as a daemaon in the user-space open and read the "state" file that appears under the directory /proc/acpi/battery/BATO/ in FC5 (I am not sure whether I can call it as a file per se). As you know, my objective is to read the remaining life-time of a battery by manipulating the rate
at which current is drawn and the total capacity. However, I find it difficult to open the required file/device probably because system continuously writes into "state" and as a result another thread cannot open it simultaneously. I have tried with fopen() and open() - both of them didn't work.

Does anybody have an idea as to how I can get around with this problem ?

Thanks in advance for taking your invaluable time to answer my question.

Best Regards,


Lenard 12-19-2006 05:47 AM

Have a look at the acpitool package, from man acpitool;


      acpitool is a Linux ACPI client. It simply reads /proc/acpi entries and
      presents the output in a meaningfull, human-readable format.

      It  provides  a.o.  information on battery status, AC adapter presence,
      thermal reading, etc. This command is most useful on  laptops  with  an
      ACPI compliant BIOS and a Linux kernel, preferably from the 2.6 series,
      with ACPI enabled.

The source code could prove helpful.

All times are GMT -5. The time now is 08:13 PM.