fix openbsd battery calc on amd64

This commit is contained in:
Al Poole 2016-06-09 11:15:09 -04:00 committed by Mike Blumenkrantz
parent 0e416648df
commit 4f1f29ae35
1 changed files with 28 additions and 5 deletions

View File

@ -111,6 +111,25 @@ _battery_openbsd_battery_update()
ecore_poller_poller_interval_set(bat->poll,
battery_config->poll_interval);
/* last full capacity */
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 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;
@ -119,13 +138,14 @@ _battery_openbsd_battery_update()
bat->last_full_charge = (double)s.value;
}
/* remaining capcity */
/* 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))
@ -133,6 +153,9 @@ _battery_openbsd_battery_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)