parent
95359855da
commit
ba22c1c4fd
|
@ -836,6 +836,7 @@ _power_battery_count_get(power_t *power)
|
|||
for (int i = 0; i < power->battery_count; i++)
|
||||
{
|
||||
power->batteries[i] = calloc(1, sizeof(bat_t));
|
||||
power->batteries[i]->present = true;
|
||||
}
|
||||
|
||||
return power->battery_count;
|
||||
|
@ -898,9 +899,8 @@ _battery_state_get(power_t *power)
|
|||
battio.unit = i;
|
||||
if (ioctl(fd, ACPIIO_BATT_GET_BIF, &battio) != -1)
|
||||
{
|
||||
power->batteries[i]->charge_full = battio.bif.lfcap;
|
||||
power->batteries[i]->charge_full = battio.bif.dcap;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "%s %s", battio.bif.oeminfo, battio.bif.model);
|
||||
power->battery_names[i] = strdup(name);
|
||||
battio.unit = i;
|
||||
|
@ -908,6 +908,10 @@ _battery_state_get(power_t *power)
|
|||
{
|
||||
power->batteries[i]->charge_current = battio.bst.cap;
|
||||
}
|
||||
if (battio.bst.state == ACPI_BATT_STAT_NOT_PRESENT)
|
||||
{
|
||||
power->batteries[i]->present = false;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ typedef struct
|
|||
double charge_full;
|
||||
double charge_current;
|
||||
uint8_t percent;
|
||||
bool present;
|
||||
} bat_t;
|
||||
|
||||
typedef struct
|
||||
|
|
|
@ -164,6 +164,9 @@ _battery_usage_add(Evas_Object *box, power_t *power)
|
|||
|
||||
for (int i = 0; i < power->battery_count; i++)
|
||||
{
|
||||
if (!power->batteries[i]->present)
|
||||
continue;
|
||||
|
||||
frame = elm_frame_add(box);
|
||||
evas_object_size_hint_align_set(frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
|
Loading…
Reference in New Issue