diff options
author | Landry Breuil <landry@rhaalovely.net> | 2011-03-06 14:10:28 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2011-03-21 18:39:19 +0000 |
commit | 89c929d442ab6b0b9c97de570b6455cbd355af0d (patch) | |
tree | fd901188c2534a16c0afe1d3f8fc409d3b021773 | |
parent | c11e803058d9453b541937c06e4ff11caad0edc7 (diff) |
openbsd: update ac state only if state really changed
Signed-off-by: Richard Hughes <richard@hughsie.com>
-rw-r--r-- | src/openbsd/up-backend.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/openbsd/up-backend.c b/src/openbsd/up-backend.c index a619f53..9e5b1ba 100644 --- a/src/openbsd/up-backend.c +++ b/src/openbsd/up-backend.c @@ -170,11 +170,17 @@ static void up_backend_update_ac_state(UpDevice* device, struct apm_power_info a) { GTimeVal timeval; - g_get_current_time (&timeval); - g_object_set (device, - "online", (a.ac_state == APM_AC_ON ? TRUE : FALSE), + gboolean new_is_online, cur_is_online; + g_object_get (device, "online", &cur_is_online, NULL); + new_is_online = (a.ac_state == APM_AC_ON ? TRUE : FALSE); + if (cur_is_online != new_is_online) + { + g_get_current_time (&timeval); + g_object_set (device, + "online", new_is_online, "update-time", (guint64) timeval.tv_sec, NULL); + } } static void |