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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user