[arch-general] Battery status files created on the fly?

Norbert Zeh nzeh at cs.dal.ca
Tue May 17 13:26:32 EDT 2011


Hi folks,

I've run into a weird problem with monitoring the status of my laptop battery.
Since I assume I'm doing something wrong, I thought I'd ask for feedback here
first before going and filing a bug report.  Here goes:

When my machine boots, /sys/class/power_supply/BAT0 and all the files in it do
not exist:

$ ls /sys/class/power_supply
AC

Since my battery monitor uses this as the source of information, it obviously
fails.

Now, as soon as I query the state of the battery through
/proc/acpi/battery/BAT0, the missing files under /sys/class/power_supply get
created:

$ cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          discharging
present rate:            1265 mA
remaining capacity:      4234 mAh
present voltage:         11340 mV

$ ls /sys/class/power_supply
AC  BAT0

This is not just a timeout issue.  If I don't query
/proc/acpi/battery/BAT0/state, /sys/class/power_supply/BAT0 does not get
created even after a few hours of uptime.

Also, after suspending, the files remain present but cannot be read.  Querying
the battery through the /proc interface once again brings everything back to
normal.

Now what's funny about this is that I read online that the /proc/acpi/battery
interface is deprecated and that the /sys/... interface should be used instead.
Yet, without querying the former, the latter doesn't even exist.

Did anybody run into similar issues?  Does anybody have any ideas how to fix
this "the proper way"?  (My workaround right now is to include "cat
/proc/acpi/battery/BAT0/state > /dev/null" in rc.local, but that's obviously a
hack.)

Thanks for any pointers you may give.

Cheers,
Norbert

PS: Machine is Dell Latitude E6510 running 64-bit ARCH.


More information about the arch-general mailing list