You are not logged in.
Pages: 1

As shown here, fastfetch returned 101 as battery %, is it just a bug or is the reader just broken?
EDIT: marking as resolved by recent reply by @lmn
Last edited by Norma Jenkins (2024-06-05 20:02:19)
Offline
What's the output from `cat /sys/class/power_supply/BAT?/capacity`? If that shows 101, then something is odd with your battery or the kernel's handling of it.
It's far more likely a fastfetch bug though. I glanced at the code and it seems to retrieve the string representation of an integer value of the percent from sysfs, but then converts that string to a floating point number only later to convert it back to an integer and then string for printing. Such repeated (and needless) conversions can result in "rounding" errors.
Last edited by Trilby (2024-06-05 17:13:34)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
What's the output from `cat /sys/class/power_supply/BAT?/capacity`? If that shows 101, then something is odd with your battery or the kernel's handling of it.
It's far more likely a fastfetch bug though. I glanced at the code and it seems to retrieve the string representation of an integer value of the percent from sysfs, but then converts that string to a floating point number only later to convert it back to an integer and then string for printing. Such repeated (and needless) conversions can result in "rounding" errors.
Actually it did output 101, in my xorg bar I have
xsetroot -name "$(cat /sys/class/power_supply/BAT1/capacity)%and from that I saw 101, later I checked fastfetch to see if one was wrong. WHat do you reccomend me to do?
Offline
The values read by the kernel from the battery are affected by the (self) calibration of the hardware. Batteries decay over time and to compensate for this behavior modern batteries routinely update their maximum capacity readings. The curve is not monotonically decreasing but can temporarily jump upwards. Whats seems to have happened here is that the current capacity surpasses the calibrated max capacity and as a result it show a value over 100%. When the next calibration is triggered the value should normalize to 100%.
Edit: As I also use this value to display the remaining capacity, i too have observed this behavior.
For those interested here is a link to graph of a real device.
Last edited by lmn (2024-06-05 19:51:43)
Offline
Pages: 1