# Making a battery/AC-IN widget: reading status from sysfs

## Spidey

So, I've managed to find /sys/class/power_supply/, and here I can find both AC-IN and battery devices, and I can probe then accordingly.

Currently, I'm setting the devices name as variables, bat = "BAT1" and acin = "ACAD" in my case. What I want to know, and it's definitely not a Gentoo specific setting, is how can I probe my system, or sysfs, for these names. I mean, there are notebooks with even more than 1 battery, how can I make a script to probe them all? I wouldn't probe all directories in /sys/class/power_supply for specific files belonging to AC-IN or battery devices, I'd rather find a static path with devices enumerate, something like "cat /sys/class/battery" and "cat /sys/class/acin".

Another question, is it correct to calculate the battery charge percentage doing (100*charge_now/charge_full), from /sys/class/power_supply/BAT1/?

----------

