discomfitor pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=4f1f29ae3510d54b2534a4b4770ec6493a480ad2

commit 4f1f29ae3510d54b2534a4b4770ec6493a480ad2
Author: Al Poole <[email protected]>
Date:   Thu Jun 9 11:15:09 2016 -0400

    fix openbsd battery calc on amd64
---
 src/modules/battery/e_mod_openbsd.c | 33 ++++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/modules/battery/e_mod_openbsd.c 
b/src/modules/battery/e_mod_openbsd.c
index 2876fb1..8a85a65 100644
--- a/src/modules/battery/e_mod_openbsd.c
+++ b/src/modules/battery/e_mod_openbsd.c
@@ -110,29 +110,52 @@ _battery_openbsd_battery_update()
        /* update the poller interval */
        ecore_poller_poller_interval_set(bat->poll,
                                         battery_config->poll_interval);
-    
+   
        /* last full capacity */
-       bat->mib[3] = 8;
+       bat->mib[3] = 7;
        bat->mib[4] = 0;
        if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
          {
             bat->last_full_charge = (double)s.value;
          }
     
-       /* remaining capcity */
-       bat->mib[3] = 8;
+       /* remaining capacity */
+       bat->mib[3] = 7;
        bat->mib[4] = 3;
        if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
          {
             charge = (double)s.value;
          }
-    
+  
+       /* This is a workaround because there's an ACPI bug */ 
+       if (charge == 0 || bat->last_full_charge == 0)
+         {
+           /* last full capacity */
+           bat->mib[3] = 8;
+           bat->mib[4] = 0;
+           if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
+             {
+                bat->last_full_charge = (double)s.value;
+             }
+
+           /* remaining capacity */
+           bat->mib[3] = 8;
+           bat->mib[4] = 3;
+           if (sysctl(bat->mib, 5, &s, &slen, NULL, 0) != -1)
+             {
+                charge = (double)s.value;
+             }
+         }
+ 
        _time = ecore_time_get();
        if ((bat->got_prop) && (charge != bat->current_charge))
          bat->charge_rate = ((charge - bat->current_charge) / (_time - 
bat->last_update));
        bat->last_update = _time;
        bat->current_charge = charge;
        bat->percent = 100 * (bat->current_charge / bat->last_full_charge);
+       if (bat->current_charge >= bat->last_full_charge)
+         bat->percent = 100;
+
        if (bat->got_prop)
          {
             if (bat->charge_rate > 0)

-- 


Reply via email to