You are not logged in.

#1 2012-01-17 03:08:38

jwhendy
Member
Registered: 2010-04-01
Posts: 612

[SOLVED] /sys/class/power_supply/BAT0 reads 0 for all power files

I'm on a Macbook 2,1 running Arch and just recently noticed that my conky started showing 2 billion % for my battery's charge. Conky simply uses:

${battery_percent BAT0}%

In any case, I've manually dug around as well in /sys/class/power_supply before to figure things out and in doing so found:

]$ ls /sys/class/power_supply/BAT0
alarm		    energy_now	  present	 type
cycle_count	    manufacturer  serial_number  uevent
device		    model_name	  status	 voltage_min_design
energy_full	    power	  subsystem	 voltage_now
energy_full_design  power_now	  technology

$ cat /sys/class/power_supply/BAT0/energy_full
0


$ cat /sys/class/power_supply/BAT0/energy_now
0

$ cat /sys/class/power_supply/BAT0/power_now
0

$ cat /sys/class/power_supply/BAT0/present
1

$ cat /sys/class/power_supply/BAT0/status
Discharging

$ cat /sys/class/power_supply/BAT0/voltage_now
0

These use to contain non-zero values such that (energy_now/energy_full)=% charge.

Any suggestions on how to figure out what happened?

Last edited by jwhendy (2012-01-18 04:49:57)

Offline

#2 2012-01-17 11:58:06

Manit0u
Member
Registered: 2012-01-17
Posts: 10

Re: [SOLVED] /sys/class/power_supply/BAT0 reads 0 for all power files

Could you try using this instead?

${battery BAT0}

And do you have acpid installed? Conky still needs something to handle the ACPI events.

Last edited by Manit0u (2012-01-17 11:59:22)

Offline

#3 2012-01-17 13:55:49

jwhendy
Member
Registered: 2010-04-01
Posts: 612

Re: [SOLVED] /sys/class/power_supply/BAT0 reads 0 for all power files

@ManitOu:

-- Using ${battery BAT0) gives me [charging], so it must be looking at /sys/class/power_supply/status.

-- I didn't have acpid installed. I don't consider the battery an "event," but could be wrong. My read of the wiki is that acpid handles buttons and lid events and the like. This is simply looking for how much battery power I have. I installed acpid and started the daemon. There doesn't seem to be a change in /sys/class files or in conky's output. Do I need to restart after adding it to rc.conf for it to take effect?

Offline

#4 2012-01-18 04:49:33

jwhendy
Member
Registered: 2010-04-01
Posts: 612

Re: [SOLVED] /sys/class/power_supply/BAT0 reads 0 for all power files

Strange. This ended up being fixed by a reboot from Arch into OS X (I dual boot) and back to Arch. I'll mark this solved here but posted on SuperUser to try and find out the root cause in a more populous setting.

Offline

#5 2012-01-18 07:28:08

Manit0u
Member
Registered: 2012-01-17
Posts: 10

Re: [SOLVED] /sys/class/power_supply/BAT0 reads 0 for all power files

You should try and deplete your battery some and then see what it looks like.
In my case ${battery BAT0} shows charged when full and when not it shows "charging 97%" for example (it checks both status and current level in %). That's why I wanted it to try it with this command instead.
Anyway, I'm glad you solved the issue.

Offline

#6 2012-01-18 15:39:10

jwhendy
Member
Registered: 2010-04-01
Posts: 612

Re: [SOLVED] /sys/class/power_supply/BAT0 reads 0 for all power files

Ah. I can try that now that it's "reset." The other night when I did that, I just got the state, which makes sense: sys/class/power_supply/BAT0/status was "Discharging" but the percent was still not present, so perhaps that's why I only saw the state.

I'm guessing that now that it's better, I'd get what you did: "discharging xx%"

Thanks for the feedback.

Offline

#7 2012-01-18 18:59:45

Manit0u
Member
Registered: 2012-01-17
Posts: 10

Re: [SOLVED] /sys/class/power_supply/BAT0 reads 0 for all power files

You can also combo this display.

I'm using:

$acpiacadapter
${battery BAT1} ${battery_time BAT1}

battery_time doesn't come up when your battery is fully charged, otherwise it shows you time left to discharge (with adapter unplugged) or charge back up to full capacity (with adapter plugged in).

Here's the result when I unplug the adapter:
Q9aK1.png

Offline

Board footer

Powered by FluxBB