Battery Info

Mar 24, 2015 at 11:50pm
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++?
Mar 26, 2015 at 12:04pm
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.
Mar 26, 2015 at 12:14pm
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.