all repos — tint2 @ b023229600dd581c53af54a1048a3304d941ff2b

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Battery: do not sample too often if the battery level changes slowly (and there is no support for reading current/power)
o9000 mrovi9000@gmail.com
commit

b023229600dd581c53af54a1048a3304d941ff2b

parent

82b71ec5b6513bef77aa5cc81e82020d41478635

1 files changed, 7 insertions(+), 0 deletions(-)

jump to
M src/battery/linux.csrc/battery/linux.c

@@ -306,6 +306,7 @@ gsize datalen;

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 @@ if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NODEV)) {

/* 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;