diff options
author | Al Poole <netstar@gmail.com> | 2016-06-09 11:15:09 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2016-07-15 09:59:54 -0400 |
commit | 89efcfd2d262123357f4d24fde70cc82a6edc7f6 (patch) | |
tree | 3352d4391965d036c96eabd44d144993c16fa2f6 | |
parent | 5d818684aa190a1b255b899dc3b16d931bd007d0 (diff) | |
download | enlightenment-89efcfd2d262123357f4d24fde70cc82a6edc7f6.tar.gz |
fix openbsd battery calc on amd64
-rw-r--r-- | src/modules/battery/e_mod_openbsd.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/modules/battery/e_mod_openbsd.c b/src/modules/battery/e_mod_openbsd.c index 2876fb15ac..8a85a653e7 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) |