ok linux question for you smart linux people. I want to add a battery indicator to my synthesizer program thingy which is a full screen program. I want to do the following:

1. not pull in any new library dependencies

2. determine whether the system is on battery or AC power

3. if it is on battery, determine the battery level as a simple percentage

4. have this work on more than one linux

proc filesystem is already off to a bad start. an old blog post I found says to simply read it from /proc/acpi/battery/, but this folder does not exist. stack overflow says to read it from /sys/class/power_supply/BAT0/ but this folder also does not exist. as it happens, my linux says it's in /sys/class/power_supply/BAT1/ for some reason. I can only conclude each linux puts the battery info in a unique location per user.
@aeva It's usually BAT0 but it can be BAT$N. Also there might be more than one, because multiple batteries are possible. So you gotta enumerate them.
@glyph @aeva It can be called other things, too! My battery info is under `/sys/class/power_supply/qcom-battmgr-bat/`. If it's a battery, it'll have a file like `energy_now` in it. (I know `i3status` reads from `uevent`, which gives a nice summary of the data in all the other files.)

@whbboyd @glyph do me a favor and tell me if you've got a command called "upower" and if so what this spits out:

upower -e

@aeva @glyph
$ upower -e
/org/freedesktop/UPower/devices/line_power_qcom_battmgr_ac
/org/freedesktop/UPower/devices/battery_qcom_battmgr_bat
/org/freedesktop/UPower/devices/line_power_qcom_battmgr_usb
/org/freedesktop/UPower/devices/line_power_qcom_battmgr_wls
/org/freedesktop/UPower/devices/DisplayDevice

Those… uh, dbus paths?… all correspond to filesystem paths under `/sys/class/power_supply`.

@whbboyd @glyph yup. upower is a dbus thing. you can read info about one of those paths by passing it into upower -i. Mine differ, but curiously DisplayDevice is a battery for me lol
@aeva @whbboyd @glyph same here (Lenovo P15v, Debian 12).
@aeva @glyph Uh, except for `DisplayDevice`. That one upower made up.