Open blueyed opened 9 years ago
Hi, It's something I've already thought about (a bit) in the past, but have not progressed yet. If I want to implement such feature, I have questions to answer first:
What's the available battery information when there is more than one battery? Is there official documentation about it? Is that information consistent between all the different models, or are there different way of working?
As an example: if I have 2 batteries available, the first one is at 80% and the second one at 20% (or the reverse), how do I know which one to take into account? what are the statuses in that case? One at status Discharging and the other in status Unknown, as yours? or other statuses are possible? If the second one is in the status Unknown, can I still reliably know if it is charged or not and up to which level?
I would have to find clear documentation about all that before starting any change. As I'm not sure I'll be able to find documentation I guess I'll have to read source code of other existing battery icon tools and guess from there what's the standard behaviour, or to contact other devs and ask for info.
In any case, I don't want to enter in a trial and error situation or to face this kind of problems: https://bugs.launchpad.net/ubuntu/+source/gnome-power-manager/+bug/379599
...and I also need to buy an second battery for testing then, because I will not release code that I cannot test.
So, quite a lot of questions/constraints to get this done.
Thanks for your reply and considering this feature!
On my machine (Lenovo X250) it looks like it will use the 2nd battery (BAT1) until it's nearly empty and then falls back to the internal one (BAT0). When charging again, first the internal one will be charged. The state of the non-uses battery seems to be "Unknown" always.
I came across cbatticon via https://wiki.archlinux.org/index.php/Laptop#ACPI, but have had my own battery widget for AwesomeWM extended in this regard: https://gist.github.com/blueyed/dcc121cbcfcdc9a67019.
Stupid question: can the external battery be connected/disconnected at any time?
Yes.
Supporting this would be great, I have a T460s, also with two internal, non exchangeable batteries
Yeah, it's the next thing I would like to do. I already prepared the work by making the detection of power supplies dynamic (instead of at launch time). I'm a bit lacking time currently, not sure when I'll have to progress on this.
@valr Any progress on it till now? I have same situation with Thinkpad X260 and two batteries.
I have another Lenovo model and I wanted to leave some more documentation of the battery interface (even though I guess you already know it):
tp_smapi
:
: https://github.com/evgeni/tp_smapi
: http://www.thinkwiki.org/wiki/Tp_smapithinkpad_acpi
:
: https://www.kernel.org/doc/Documentation/laptops/thinkpad-acpi.txt
: http://www.thinkwiki.org/wiki/Thinkpad-acpiMy experience is consistent with what has been described above:
Only BAT1
is discharging, BAT0
stays at 78.
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/capacity
78
38
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/status
Unknown
Discharging
I assume the Unknown
state can be translated into the Idle
state from smapi
as seen in #31.
And it automatically switches from BAT1
to BAT0
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/{capacity,status}
99
5
Unknown
Discharging
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/{capacity,status}
98
5
Discharging
Unknown
After charging it a few minutes, only BAT1
is charging. I guess BAT0
's 78->79 is some kind of rounding or measurement error.
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/capacity
79
51
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/status
Unknown
Charging
BAT1
got stuck at 99% for around 30 minutes, but it eventually started charging BAT0
(Unknown
and Charging
flipped):
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/{capacity,status}
85
99
Charging
Unknown
When both are fully charged, it turns into a double Unknown
# cat /sys/bus/acpi/drivers/battery/PNP0C0A\:0[01]/power_supply/BAT[01]/{capacity,status}
99
98
Unknown
Unknown
The only differences between the two batteries I could find, was serial_number
and model_name
. Of course all the technical values (e.g. energy_full
, alarm
, etc) also deviated.
After hot-unplugging the BAT1
, it just disappeared from the sysfs interface. Even after hot-plugging it back in, it did not re-appear in the sysfs interface. Only a reboot will let it re-appear.
@EoD, thanks a lot for the info. It's very usefull as I don't have such hardware. @mbroemme, I hope to start working on this in the coming weeks. In the meantine, could you check the post of EoD and check if it's working the same way on your hardware?
@valr, it is the same for me. The difference between both batteries is serial_number, capacity, energy_full, energy_full_design and energy_now as they are dynamic values.
BAT0 seems always the internal one and BAT1 the external one which can be removed on-the-fly. After hotplug BAT1 is removed from sysfs on my X260 too.
I added some more information about charging into the post above. I might update the post in the future for the case that both are (almost) empty.
@valr I am glad to hear that you are working on it.
Seems there is no progress on this. Do you need someone to work on this?
@hasufell , I'm busy reworking the code. In its current state it would not be possible to implement multiple batteries (or that would be super ugly). I should do some commits in the coming days with the reworked code.
Any update on this? I have a Surface Book 2 and would love to see the status of the two batteries. Especially hot-unplugging and hot-plugging, since the screen is also a tablet and I tend to unplug/replug it often.
In my Lenovo X250 I have two batteries: one "external" that can be removed (BAT1) and an internal one (BAT0).
The internal one gets used automatically when the external one is empty (at 5%), and the status of the external one (BAT1) is
battery status: 1 - Unknown
then (see also issue #16).It would be nice, if cbatticon could monitor both at the same time, preferring BAT1 and falling back to BAT0.
For this to be really useful it would be nice to have the information about the displayed battery in the tooltip (and maybe (optionally) in the icon).