diff --git a/src/bin/system.c b/src/bin/system.c index d18fdb0..8445ab2 100644 --- a/src/bin/system.c +++ b/src/bin/system.c @@ -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); diff --git a/src/bin/system.h b/src/bin/system.h index 545eb94..ab2693a 100644 --- a/src/bin/system.h +++ b/src/bin/system.h @@ -29,6 +29,7 @@ typedef struct double charge_full; double charge_current; uint8_t percent; + bool present; } bat_t; typedef struct diff --git a/src/bin/ui.c b/src/bin/ui.c index 29c73a7..f4b5694 100644 --- a/src/bin/ui.c +++ b/src/bin/ui.c @@ -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);