+
+function aggregate_battery_percentage( bat, curr, full) {
+ _battery_energy[device["native_path"]] = device["energy"]
+ _battery_energy_full[device["native_path"]] = device["energy_full"]
+ for (bat in _battery_energy) {
+ curr = curr + _battery_energy[bat]
+ full = full + _battery_energy_full[bat]
+ }
+ return ((curr / full) * 100)
+}
+
+function aggregate_battery_state( curr, bat, new) {
+ _battery_state[device["native_path"]] = device["battery_state"]
+ curr = device["battery_state"]
+ for (bat in _battery_state) {
+ new = _battery_state[bat]
+ if (new == "discharging") {
+ curr = new
+ } else if (curr != "discharging" && new == "charging") {
+ curr = new
+ }
+ }
+ return curr
+}