diff --git a/xcpmd/src/battery.c b/xcpmd/src/battery.c index d5c8e263..7805452d 100644 --- a/xcpmd/src/battery.c +++ b/xcpmd/src/battery.c @@ -859,9 +859,16 @@ void update_batteries(void) { } if ((old_array_size != new_array_size) || (memcmp(old_status, last_status, new_array_size * sizeof(struct battery_status)))) { - //Here for compatibility--should eventually be removed - xenstore_write("1", XS_BATTERY_STATUS_CHANGE_EVENT_PATH); - notify_com_citrix_xenclient_xcpmd_battery_status_changed(xcdbus_conn, XCPMD_SERVICE, XCPMD_PATH, get_overall_battery_percentage()); + static int previous_percent; + int current_percent = get_overall_battery_percentage(); + + if (current_percent != previous_percent) { + previous_percent = current_percent; + //Here for compatibility--should eventually be removed + xenstore_write("1", XS_BATTERY_STATUS_CHANGE_EVENT_PATH); + notify_com_citrix_xenclient_xcpmd_battery_status_changed( + xcdbus_conn, XCPMD_SERVICE, XCPMD_PATH, current_percent); + } } if (present_batteries_changed) {