Battery Info

How do I get the battery percent, if the battery is charging or not, if it is connected to the ac adapter, and the temperature in linux using c/c++?
Look at virtual files in
/sys/class/power_supply/BAT0/
and
/sys/class/thermal/thermal_zone0/
you may read them using traditional I/O

Another option is to use external application to get it for you, look at "acpi" command.
You can call it using system() call.
And yet another more elegant option is to use D-Bus. See what you can get from
org.freedesktop.UPower.Device:
http://upower.freedesktop.org/docs/Device.html
Topic archived. No new replies allowed.