diff --git a/src/battery/linux.c b/src/battery/linux.c index 54af607..97f43e7 100644 --- a/src/battery/linux.c +++ b/src/battery/linux.c @@ -306,6 +306,7 @@ static gboolean update_linux_battery(struct psy_battery *bat) gint64 old_timestamp = bat->timestamp; int old_energy_now = bat->energy_now; + gint old_power_now = bat->power_now; /* reset values */ bat->present = 0; @@ -356,6 +357,12 @@ static gboolean update_linux_battery(struct psy_battery *bat) /* some hardware does not support reading current power consumption */ g_error_free(error); bat->power_now = estimate_power_usage(bat, old_energy_now, old_timestamp); + if (bat->power_now == 0 && bat->status != BATTERY_FULL) { + /* If the hardware updates the level slower than our sampling period, + * we need to sample more rarely */ + bat->power_now = old_power_now; + bat->timestamp = old_timestamp; + } } else if (error) { g_error_free(error); return FALSE;