This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository enlightenment.

View the commit online.

commit 4d5b59459f10d876a7bb463f0ce3bcb98be44dde
Author: Carsten Haitzler <ras...@rasterman.com>
AuthorDate: Mon Sep 16 13:33:00 2024 +0100

    battery - flter out "0 full charge" batteries - they seem to be dummy
    
    fix battery guage appearing at 1/2 due to it thinking you have 2
    batteries (or more) where some are just dummy devices.
    
    @fix
---
 src/modules/battery/e_mod_udev.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/modules/battery/e_mod_udev.c b/src/modules/battery/e_mod_udev.c
index 6ab5def6e..e43b20521 100644
--- a/src/modules/battery/e_mod_udev.c
+++ b/src/modules/battery/e_mod_udev.c
@@ -96,7 +96,9 @@ static void
 _battery_udev_battery_add(const char *syspath)
 {
    Battery *bat;
-   const char *type;
+   const char *type, *test;
+   double full_design = 0.0;
+   double full = 0.0;
 
    if ((bat = _battery_battery_find(syspath)))
      {
@@ -120,6 +122,31 @@ _battery_udev_battery_add(const char *syspath)
           }
         eina_stringshare_del(type);
      }
+   // filter out dummy batteries with no design and no full charge level
+   test = eeze_udev_syspath_get_property(syspath, "POWER_SUPPLY_ENERGY_FULL_DESIGN");
+   if (!test)
+     test = eeze_udev_syspath_get_property(syspath, "POWER_SUPPLY_CHARGE_FULL_DESIGN");
+   if (test)
+    {
+      full_design = strtod(test, NULL);
+      eina_stringshare_del(test);
+    }
+
+   test = eeze_udev_syspath_get_property(syspath, "POWER_SUPPLY_ENERGY_FULL");
+   if (!test)
+     test = eeze_udev_syspath_get_property(syspath, "POWER_SUPPLY_CHARGE_FULL");
+   if (test)
+    {
+      full = strtod(test, NULL);
+      eina_stringshare_del(test);
+    }
+
+   if ((eina_dbl_exact(full_design, 0)) &&
+       (eina_dbl_exact(full, 0)))
+    { // ignore this battery - no full and no full design
+      return;
+    }
+
    if (!(bat = E_NEW(Battery, 1)))
      {
         eina_stringshare_del(syspath);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to