[amiwm] MVP for initial battery stuff

Totally not ready for prod, but at least I'm making progress
figuring out how to add extra bits to this thing.

* add a second widget to the menu bar, next to the title bar
* add a new module command to update the battery information
* add a freebsd specific Battery module, not linked into the
  build right now.
* amiwm will print out whenever we get battery information from the
  module.

Right now I'm trying to figure out how to get some kind of periodic
background event into the module main loop.  Launcher does it
using cx_broker(), but I dunno if I can adapt that pattern here.
This commit is contained in:
Adrian Chadd
2022-04-25 21:28:49 -07:00
parent e42512c034
commit 18e858ae80
8 changed files with 235 additions and 6 deletions

View File

@@ -490,6 +490,27 @@ static void handle_module_cmd(struct module *m, char *data, int data_len)
} else
reply_module(m, NULL, -1);
break;
case MCMD_UPDATE_BATTERY:
{
struct mcmd_update_battery *batt;
if (data_len != sizeof(struct mcmd_update_battery)) {
reply_module(m, NULL, -1);
break;
}
batt = (void *) data;
fprintf(stderr, "%s: called, BATTERY, pct=%d, time=%d, ac=%d\n",
__func__,
batt->battery_pct,
batt->battery_time,
batt->battery_ac);
/* XXX TODO: update the battery menu thingy here */
reply_module(m, NULL, 0);
break;
}
break;
default:
reply_module(m, NULL, -1);
}