Comments (14)
Btw if upstream doesn't respond after a while, I can also look into forking the crate and including your fix to help get it out.
from bottom.
Btw if upstream doesn't respond after a while, I can also look into forking the crate and including your fix to help get it out.
The upstream approves my PR, waiting for someone to merge it.
from bottom.
Thanks, can reproduce. It's probably an issue with an upstream dependency, I'll investigate.
from bottom.
Hm. Just some rambling as I debug this issue.
So I'm wondering if something's strange with what macOS reports - if I run ioreg -l -w0 | grep Capacity
to get battery stats:
"MaxCapacity" = 100
"DesignCapacity" = 6075
"AppleRawMaxCapacity" = 5643
Which gives a calculated "battery health" of ~1.65 percent, if you divide the current max capacity by the designed capacity. This is how the library bottom uses calculates it, which you can see if you run btm --battery
![image](https://private-user-images.githubusercontent.com/34804052/239723877-7d13a6ac-3afb-4d4b-bfd7-68ba45db4f1b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDU1MjI0MTEsIm5iZiI6MTcwNTUyMjExMSwicGF0aCI6Ii8zNDgwNDA1Mi8yMzk3MjM4NzctN2QxM2E2YWMtM2FmYi00ZDRiLWJmZDctNjhiYTQ1ZGI0ZjFiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAxMTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMTE3VDIwMDgzMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTY3ZmE5NmY0NjQzNjIxODJiZTk2MTViMmUyOTg2ODk5MGYxNDUyZGZmOGRiMjA3Y2RhYjIzMmU3OTdjZGI5NzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.k4j_DPSqSdIh1izZ779mmqt46yDzHWFXTo4PFfSMENo)
Matches perfectly, 1.65%.
But as you noted, this is definitely wrong, if I check in settings, I have about 97% battery health. But I'm also not sure what I'm supposed to do then if what macOS is spitting out seems... wrong then? I could try using the raw max value which is closer, but that's still wrong (5643 / 6075 gives 93%, which still doesn't match what I see in Settings).
from bottom.
And right as I post the comment, I think I figured out what I need... but I might need some extra information.
I think the columns I need are AppleRawMaxCapacity
and NominalChargeCapacity
- for me, this is:
"NominalChargeCapacity" = 5793
"AppleRawMaxCapacity" = 5643
5643 / 5793 = 97.4% - which is what I see in Settings! So this might be it - if it is, I'll submit and/or fork a patch.
Could you help me confirm if this is the case by running ioreg -l -w0 | grep Capacity
and giving me back:
NominalChargeCapacity
AppleRawMaxCapacity
MaxCapacity
DesignCapacity
Thanks!
from bottom.
Hi, glad to receive your timely reply, here is what I get:
NominalChargeCapacity 4507
AppleRawMaxCapacity 4377
MaxCapacity 100
DesignCapacity 4382
BTW, there is a Health Information
section if you run system_profiler detailLevel=mini SPPowerDataType
, but as it also reports Maximum Capacity
so I'm not sure if it's what we need here.
from bottom.
If it's possible, can I get the honour to fix this issue? I'm a recent graduate and seeking opportunities to build my reputation and contribution to FOSS.
from bottom.
Go for it! I think the best place to look to make a change is https://github.com/starship/rust-battery to fix it upstream for everyone.
from bottom.
Somehow I feel the bug is caused by different physics units. rust-battery
represents energy
in joule
, but MacOS returns energy
in mAh
.
from bottom.
Well, I got stuck at fixing it, and might need your help. My modifications cannot satisfy both our cases.
Your case:
"MaxCapacity" = 100
"DesignCapacity" = 6075
"AppleRawMaxCapacity" = 5643
"NominalChargeCapacity" = 5793
and ground truth battery health: 97%
My case:
AppleRawCurrentCapacity = 3338
AppleRawMaxCapacity = 4380
DesignCapacity = 4382
NominalChargeCapacity = 4515
and ground truth battery percentage: 80%, ground truth battery health: 100%
In file rust-battery/src/platform/darwin/iokit/power_source.rs
, if I change
static MAX_CAPACITY_KEY: &str = "MaxCapacity";
static CURRENT_CAPACITY_KEY: &str = "CurrentCapacity";
to
static MAX_CAPACITY_KEY: &str = "AppleRawMaxCapacity";
static CURRENT_CAPACITY_KEY: &str = "AppleRawCurrentCapacity";
then it match my battery health, but does not match my battery percentage and your battery health.
If, in addition to the previous two modifications, change:
static DESIGN_CAPACITY_KEY: &str = "DesignCapacity";
to
static DESIGN_CAPACITY_KEY: &str = "NominalChargeCapacity";
Then, it does not match my percentage and health, but can match yours. :-(
Currently I have no idea why it bahaves in such a strange way. The only thing I can think of is I turned on Charge on hold, but I don't think it makes a difference.
I'd appreciate it if you could give me some guidelines/ideas. Cheers.
from bottom.
Some quick looking around gives this thread which might be helpful to take a peek at. Note that whatever bottom/starship-battery is doing on at least M1, it's definitely wrong, so it does need to change for sure.
Also I'm curious if anyone has an Intel macbook to see if this is just an Apple Silicon issue or an overall macOS issue.
from bottom.
Merge Request created: starship/rust-battery#33
This fix only affects M-series-chip Mac as we have no idea if it's a bug for Intel-chip Mac.
I'll accept the fact that Apple might use some other data source to calculate battery percentage to deliver a better "user experience".
from bottom.
PR merged, and this bug will be fixed in the next version, 0.8.1
, of rust-battery
. \o/
Happy to be a FOSS contributor :-)
from bottom.
Thanks for fixing this! I'll make the relevant dependency bumps to include your fix (or if you want, you can also feel free to submit a PR), and I'll probably do a stable release sometime this week that fixes a few bugs.
from bottom.
Related Issues (20)
- Add option to subtract ARC/ZFS cache from total memory usage HOT 14
- Lock Processes pane selection in place HOT 1
- Add parameter to sort processes by memory HOT 2
- Left/Right in a process tree should collapse/expand the tree branches HOT 5
- QEMU/KVM CPU usage only shown in process list, not in overall CPU usage HOT 1
- Provide an openSUSE installer. HOT 1
- Vivaldi process fails to group due to CLI flags HOT 2
- Please upgrade dependency on toml_edit to branch v0.21 HOT 2
- Incorrect --help text about gruvbox HOT 2
- Arrow keys dont work instantly when --default_widget_type is set to CPU HOT 7
- Add option to save the previously selected widget for next launch
- Support reading lm-sensors configuration HOT 1
- Allow for selecting the average CPU by default when starting bottom HOT 1
- Nightly builds aren't being generated nightly HOT 2
- Use thinner indicators in bar graphs. HOT 6
- Show applied filters in the title bar of the processes widget HOT 1
- Prefer showing more disks than more mount points HOT 4
- Temperature Over Time HOT 5
- json schema support HOT 2
- Output metrics for later plotting and analysis HOT 1
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 bottom.