the files in my /sys/class/power_supply/BAT0/ directory seem to keep changing between "charge_" and "energy_", so for example the file containing the battery charge has just switched from "energy_now" to "charge_now", which makes it difficult to maintain scripts to interrogate these values. Are others experiencing this too, or is it just me? Will there be a final naming convention settled upon or will they keep changing? Is there a way I can abstract my scripts to work with any file names in that directory?
So if boot with AC plugged in the /sys/class/power_supply/BAT0/ directory is populated with charge_*, but if I boot on battery the directory is populated with energy_*. Is this true for everyone? I'm running a Thinkpad X220.
btw, (un)plugging AC while running does not alter the file names.
Last edited by JamieKitson (2011-11-28 21:32:05)
Just booted off battery and I have:
x220:~$ ls /sys/class/power_supply/BAT0/ | sort alarm charge_full charge_full_design charge_now current_now cycle_count device manufacturer model_name power present serial_number status subsystem technology type uevent voltage_min_design voltage_no
Same as what I did when I booted off AC.
Linux x220 3.1.2-1-ARCH #1 SMP PREEMPT Tue Nov 22 09:17:56 CET 2011 x86_64 Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz GenuineIntel GNU/Linux
Woops, I can now confirm the same behaviour that Jamie notices.
Boot off AC and I can get charge_. Boot off battery and I get energy_.
Linux x220 3.1.5-1-ARCH #1 SMP PREEMPT Sat Dec 10 14:43:09 CET 2011 x86_64 Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz GenuineIntel GNU/Linux
Booting on battery gives me energy_ and resuming from suspend changes it to charge_.
(also an x220)
Linux thinkpad 3.1.8-1-ARCH #1 SMP PREEMPT Sat Jan 7 08:59:43 CET 2012 x86_64 Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz GenuineIntel GNU/Linux
Apparently this is a feature/bug in the X220 acpi firmware. It reports units in either amps (current/charge) or watts (energy).