Comments (18)
Okay, @HarshDobariya79. I will leave it open in case you or someone else wants to pick this up in future.
from bat.
I implemented this health feature in my fork of this repo, but I think the repos have already diverged quite a bit... https://github.com/pepa65/bat
Ah.. That's bad. Seems like the entire repo has been re-fractored.
from bat.
Yes, it seemed overly complex so I did a rewrite.
@pepa65, is that the charge_full_design
variable? I have none of those on my device.
from bat.
I see. You're right, it probably also depends on the battery model.
from bat.
A note about the implementation of @sravan-s: it uses energy_full
and energy_full_design
. Maybe you have those on your system, @tshakalekholoane ? I now implemented both, so you can try it out (or just merge @sravan-s's work).
from bat.
@pepa65 I found something interesting in this doc ->
https://www.kernel.org/doc/Documentation/power/power_supply_class.txt
~ ~ ~ ~ ~ ~ ~ Charge/Energy/Capacity - how to not confuse ~ ~ ~ ~ ~ ~ ~
~ ~
~ Because both "charge" (µAh) and "energy" (µWh) represents "capacity" ~
~ of battery, this class distinguish these terms. Don't mix them! ~
~ ~
~ CHARGE_* attributes represents capacity in µAh only. ~
~ ENERGY_* attributes represents capacity in µWh only. ~
~ CAPACITY attribute represents capacity in *percents*, from 0 to 100. ~
~ ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
CHARGE_FULL_DESIGN, CHARGE_EMPTY_DESIGN - design charge values, when
battery considered full/empty.
ENERGY_FULL_DESIGN, ENERGY_EMPTY_DESIGN - same as above but for energy.
And from upower docs ->
The capacity of the power source expressed as a percentage between 0 and 100.
The capacity of the battery will reduce with age.
A capacity value less than 75% is usually a sign that you should renew your battery.
Typically this value is the same as (full-design / full) * 100.
However, some primitive power sources are not capable reporting capacity and in this
case the capacity property will be unset.
So, as you said, energy/capacity either should be fine. .If neither exist, we can assume power source have some issue
Yeah, we can try/merge your solution or mine, all good ~
from bat.
Hello @tshakalekholoane Thanks for the program ~ I use it on my laptop to set charge threshold
I was looking at battery health too. health is same as capacity, correct? https://upower.freedesktop.org/docs/Device.html#id-1.2.4.8.92
Upower calculates it using
energy_full / energy_design
https://gitlab.freedesktop.org/upower/upower/-/blob/master/src/up-device-battery.c#L307main...sravan-s:bat:feat/health This worked for me
Hi @sravan-s. It appears so! Thank you for sharing.
A note about the implementation of @sravan-s: it uses
energy_full
andenergy_full_design
. Maybe you have those on your system, @tshakalekholoane ? I now implemented both, so you can try it out (or just merge @sravan-s's work).
@pepa65, I do have those energy_full
and energy_full_design
but not the others so I will probably go with those. Both implementation look great!
Although I do have a preference for something more minimal so something like what @sravan-s did except with fmt.Sscanf
instead of defining a function.
var v, w int
_, err := fmt.Sscanf(mustRead("energy_full"), "%d\n", &v)
// ...
I also like @pepa65's implementation of the calculation, v*100/w
, which avoids floating-point arithmetic.
You are both welcome to file a pull requests or I can just do it and credit you both since you did the bulk of the research.
Also, the upower documentation you linked seems to say (full-design / full) * 100 which would be > 1, unless I am missing something?
But either way, thank you all for you contribution!
from bat.
This is interesting. Would you like to help with this, @HarshDobariya79?
from bat.
Thank you for the opportunity @tshakalekholoane, I would love to but unfortunately I don't have any experience in GO language.
from bat.
I implemented this health feature in my fork of this repo, but I think the repos have already diverged quite a bit... https://github.com/pepa65/bat
from bat.
This repo has recently been refactored a lot, and since I liked to give a different CLI experience, it's divergent. But the core ideas are exactly the same.
from bat.
I thought health
would be charge_full
divided by charge_full_design
, but if that last one doesn't exist on some ASUS models, than that's sad... Are those /sys
entries provided through a module? Perhaps version dependent??
from bat.
I believe so. For ASUS devices the charge threshold seems to be in linux/drivers/platform/x86/asus-wmi.c. The others i.e. charge_full
, I am not sure. Maybe in linux/drivers/power/supply depending on the model 🤷.
from bat.
On 5.19.0-43-generic #44~22.04.1-Ubuntu
and on 5.15.0-75-generic
charge_full_design
is exposed here (and perhaps it also depends on the battery model?).
It seems to be in asus-wmi
: https://www.spinics.net/lists/platform-driver-x86/msg19387.html and https://www.spinics.net/lists/platform-driver-x86/msg19537.html
from bat.
Hello @tshakalekholoane
Thanks for the program ~ I use it on my laptop to set charge threshold
I was looking at battery health too.
health is same as capacity, correct? https://upower.freedesktop.org/docs/Device.html#id-1.2.4.8.92
Upower calculates it using energy_full / energy_design
https://gitlab.freedesktop.org/upower/upower/-/blob/master/src/up-device-battery.c#L307
main...sravan-s:bat:feat/health
This worked for me
from bat.
Interesting about the Ampere vs. Watt, so yes, don't mix them..! How I have implemented it, they don't, so that's good.
I wonder if that depends on the battery, which are used.
from bat.
@pepa65 Feel free to make PR 😃
from bat.
@sravan-s Don't you already have a ready-to-go implementation? (I guess you don't handle charge_
entries...)
In any case, my fork is too divergent. 🤷🏼♂️
from bat.
Related Issues (20)
- issue: Charging does not stop no matter if the laptop is running or sleeping HOT 5
- issue: How to set charge resume level? HOT 3
- issue: Fails to build: cannot load embed: malformed module path "embed" HOT 3
- Works with T14 Gen2 Intel ThinkPads HOT 1
- issue: bat uninstall HOT 6
- issue: Could not find Bash on NixOS while setting persist mode HOT 5
- bat-asus-battery-bin package on AUR failed to build HOT 2
- Not working. After connect charger battery charging. ASUS TUF Gaming F17 FX706HE_FX706HE 1.0 HOT 2
- issue: when i run " # ./bat --threshold" HOT 1
- Request procedure how to update the app HOT 5
- Use system call to retrieve the Linux kernel version
- Run CI checks in parallel
- issue: 目前本人用thinkpad t15g gen1 移动工作站,以后可能换dell precision,请贵编以后加强下dell HOT 1
- issue: Battery percentage setting doesn't persist; systemctl does not indicate that [email protected] is running. HOT 44
- feat: replace dependency on Bash with /bin/sh for cross-platform compatibility
- Not working on Asus Zenbook with Ubuntu 23.04 HOT 6
- build: create additional Make targets
- issue: charge threshold not working after waking up from sleep HOT 19
- build: package bat for NixOS HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bat.