Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Display battery percentage as weighted average of battery levels #2126

Closed
bruceblore opened this issue Apr 20, 2023 · 3 comments

Comments

@bruceblore
Copy link
Contributor

Right now, if you are using a laptop with multiple batteries, it appears that the displayed capacity percentage is just an average of the capacity levels of the individual batteries. This is fine if the batteries are of a similar size, but if the batteries are of significantly different sizes, this can result in the reported percentage not being an accurate representation of how much battery life remains.

For example, it is common for thinkpads to have a 24 WHr internal battery and a 72 WHr removable battery, and to use the removable battery first. The first 50% reported by Waybar will last a long time because the first battery is large. But the second 50% will not last nearly as long. At the moment where 50% is displayed, the laptop really only has 25% of its overall capacity left. In the opposite scenario with the internal battery drained but the removable battery completely full, Waybar still displays 50%, but the laptop has 75% of its overall capacity left.

By using the weighted average of battery capacity levels, with the battery capacities as weights, the battery percentage displayed by Waybar would be much more accurate. It would probably be best to make this optional, in case someone prefers the existing behavior. And it would probably be good to use the design-capacity option to determine whether current capacity or design capacity gets used in the calculation.

@bruceblore
Copy link
Contributor Author

I just got some free time and decided to try implementing this myself in pull request #2134. Should I close this issue?

@Alexays Alexays closed this as completed Sep 4, 2023
@Icey-Glitch
Copy link

@bruceblore i was wondering you provide an example of how to use what you added. i have a thinkpad and avg of the 2 bats would be great. thanks!

@bruceblore
Copy link
Contributor Author

bruceblore commented Sep 16, 2023

"battery": {
    "weighted-average": true
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants