summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham <hisham@gobolinux.org>2017-02-15 22:47:03 -0200
committerHisham <hisham@gobolinux.org>2017-02-15 22:47:03 -0200
commitbb8dec15829bb90ef2e637312e45e90b8ab4c64b (patch)
tree6ca48adb42a60bd20d1e08905008b67e54f6cff4
parent8af4d9f453ffa2209e486418811f7652822951c6 (diff)
Cap battery at 100%.
Apparently invalid results can be returned by buggy drivers in old laptops, as reported by @thukydides. See #596.
-rw-r--r--linux/Battery.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/linux/Battery.c b/linux/Battery.c
index b7a004ba..4bee340b 100644
--- a/linux/Battery.c
+++ b/linux/Battery.c
@@ -310,6 +310,9 @@ void Battery_getData(double* level, ACPresence* isOnAC) {
*level = -1;
*isOnAC = AC_ERROR;
}
+ if (*level > 100.0) {
+ *level = 100.0;
+ }
Battery_cacheLevel = *level;
Battery_cacheIsOnAC = *isOnAC;
Battery_cacheTime = now;

© 2014-2024 Faster IT GmbH | imprint | privacy policy