[hackers] [slstatus] Add 'Not charging' status support || Spenser Truex

From: <git_AT_suckless.org>
Date: Wed, 26 Oct 2022 21:38:28 +0200 (CEST)

commit f29aa9ab0656c938ad0c0d4a6136ff25bd82ebf9
Author: Spenser Truex <truex_AT_equwal.com>
AuthorDate: Wed Oct 26 21:34:47 2022 +0200
Commit: drkhsh <me_AT_drkhsh.at>
CommitDate: Wed Oct 26 21:34:58 2022 +0200

    Add 'Not charging' status support
    
    Exists on various ThinkPads. Seems to be both a synonym for "full".
    
    Tested on:
    - ThinkPad T500 (Spenser Truex <truex_AT_equwal.com)
    - ThinkPad T420 (drkhsh <me_AT_drkhsh.at)

diff --git a/components/battery.c b/components/battery.c
index f2b0f14..a36132d 100644
--- a/components/battery.c
+++ b/components/battery.c
_AT_@ -53,6 +53,7 @@
                         { "Charging", "+" },
                         { "Discharging", "-" },
                         { "Full", "o" },
+ { "Not charging", "o" },
                 };
                 size_t i;
                 char path[PATH_MAX], state[12];
_AT_@ -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;
                 }
 
_AT_@ -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;
                 }
 
Received on Wed Oct 26 2022 - 21:38:28 CEST

This archive was generated by hypermail 2.3.0 : Wed Oct 26 2022 - 21:48:33 CEST