netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=007afba7716dac1fdf15f3c325c9418b81ea8982

commit 007afba7716dac1fdf15f3c325c9418b81ea8982
Author: Alastair Poole <nets...@gmail.com>
Date:   Sat Apr 3 08:59:27 2021 +0100

    sensors: battery present linux.
---
 src/bin/system/machine/sensors.bogox | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/bin/system/machine/sensors.bogox 
b/src/bin/system/machine/sensors.bogox
index c4d76db..64a9fb3 100644
--- a/src/bin/system/machine/sensors.bogox
+++ b/src/bin/system/machine/sensors.bogox
@@ -301,6 +301,7 @@ _power_battery_count_get(power_t *power)
 #elif defined(__linux__)
    char *type;
    struct dirent **names;
+   char *buf;
    char path[PATH_MAX];
    int i, n, id;
 
@@ -324,7 +325,14 @@ _power_battery_count_get(power_t *power)
                   power->batteries[id]->vendor = file_contents(path);
                   snprintf(path, sizeof(path), 
"/sys/class/power_supply/%s/model_name", names[i]->d_name);
                   power->batteries[id]->model = file_contents(path);
-                  power->batteries[id]->present = true;
+                  snprintf(path, sizeof(path), 
"/sys/class/power_supply/%s/present", names[i]->d_name);
+                  buf = file_contents(path);
+                  if (buf)
+                    {
+                       power->batteries[id]->present = atoi(buf);
+                       free(buf);
+                    }
+
                   power->battery_count++;
                }
              free(type);

-- 


Reply via email to