Battery: support for ac connection event cmd

This add two new config options "ac_connected_cmd" and
"ac_disconnected_cmd". These commands are executed when
AC (mains supply) is connected or disconnected.
This commit is contained in:
Sebastian Reichel
2015-08-07 05:20:24 +02:00
parent 3c45cf29c7
commit db490247e0
4 changed files with 33 additions and 0 deletions

View File

@@ -343,6 +343,7 @@ int battery_os_update(struct batstate *state) {
gboolean charging = FALSE;
gboolean discharging = FALSE;
gboolean full = FALSE;
gboolean ac_connected = FALSE;
for (l = batteries; l != NULL; l = l->next) {
struct psy_battery *bat = l->data;
@@ -360,6 +361,7 @@ int battery_os_update(struct batstate *state) {
for (l = mains; l != NULL; l = l->next) {
struct psy_mains *ac = l->data;
update_linux_mains(ac);
ac_connected |= (ac->online);
}
/* build global state */
@@ -382,6 +384,9 @@ int battery_os_update(struct batstate *state) {
/* calculate percentage */
state->percentage = energy_to_percent(total_energy_now, total_energy_full);
/* AC state */
state->ac_connected = ac_connected;
return 0;
}