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.