summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpenser Truex <truex@equwal.com>2022-10-26 21:34:47 +0200
committerRafael Marçalo <raroma09@gmail.com>2022-10-27 12:59:29 +0100
commit9b057c200881fa54d1d64d4de685d2e2fa52bb52 (patch)
treeb66b63cefe402f3b64df1a03ce95704111644f6c
parent7f125162fa30ae2d1fbf318dc0e961410a07bf8a (diff)
Add 'Not charging' status support
Exists on various ThinkPads. Seems to be both a synonym for "full". Tested on: - ThinkPad T500 (Spenser Truex <truex@equwal.com) - ThinkPad T420 (drkhsh <me@drkhsh.at)
-rw-r--r--components/battery.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/components/battery.c b/components/battery.c
index f2b0f14..a36132d 100644
--- a/components/battery.c
+++ b/components/battery.c
@@ -53,6 +53,7 @@
{ "Charging", "+" },
{ "Discharging", "-" },
{ "Full", "o" },
+ { "Not charging", "o" },
};
size_t i;
char path[PATH_MAX], state[12];
@@ -61,7 +62,7 @@
"/sys/class/power_supply/%s/status", bat) < 0) {
return NULL;
}
- if (pscanf(path, "%12s", state) != 1) {
+ if (pscanf(path, "%12[a-zA-Z ]", state) != 1) {
return NULL;
}
@@ -84,7 +85,7 @@
"/sys/class/power_supply/%s/status", bat) < 0) {
return NULL;
}
- if (pscanf(path, "%12s", state) != 1) {
+ if (pscanf(path, "%12[a-zA-Z ]", state) != 1) {
return NULL;
}