From 555a10ef6511c47bd19a26280ab28990fb2e3693 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Thu, 13 Jun 2019 19:04:11 -0700 Subject: [PATCH] battery: only submit event if battery value changed --- src/libsysprof/sysprof-battery-source.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libsysprof/sysprof-battery-source.c b/src/libsysprof/sysprof-battery-source.c index a978bee8..0b12a6e7 100644 --- a/src/libsysprof/sysprof-battery-source.c +++ b/src/libsysprof/sysprof-battery-source.c @@ -157,6 +157,7 @@ static gboolean battery_poll (Battery *battery, SysprofCaptureCounterValue *value) { + gint64 val; gssize len; gchar buf[32]; @@ -183,11 +184,16 @@ battery_poll (Battery *battery, buf [len] = 0; - battery->charge_now = atoi (buf); + val = atoi (buf); - value->v64 = battery->charge_now; + if (val != battery->charge_now) + { + battery->charge_now = val; + value->v64 = val; + return TRUE; + } - return TRUE; + return FALSE; } static gboolean