Skip to content

Commit

Permalink
Merge pull request #72 from jandryuk/fewer-dbus-signals
Browse files Browse the repository at this point in the history
xcpmd: Send battery changed when the percent changes
  • Loading branch information
crogers1 authored Sep 29, 2022
2 parents 0c30242 + 7cd378d commit d949b71
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions xcpmd/src/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d949b71

Please sign in to comment.