cfg_opt_t battery_opts[] = {
CFG_STR("format", "%status %percentage %remaining", CFGF_NONE),
+ CFG_STR("path", "/sys/class/power_supply/BAT%d/uevent", CFGF_NONE),
CFG_BOOL("last_full_capacity", false, CFGF_NONE),
CFG_END()
};
print_eth_info(title, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down"));
CASE_SEC_TITLE("battery")
- print_battery_info(atoi(title), cfg_getstr(sec, "format"), cfg_getbool(sec, "last_full_capacity"));
+ print_battery_info(atoi(title), cfg_getstr(sec, "path"), cfg_getstr(sec, "format"), cfg_getbool(sec, "last_full_capacity"));
CASE_SEC_TITLE("run_watch")
print_run_watch(title, cfg_getstr(sec, "pidfile"), cfg_getstr(sec, "format"));
void print_ipv6_info(const char *format_up, const char *format_down);
void print_disk_info(const char *path, const char *format);
-void print_battery_info(int number, const char *format, bool last_full_capacity);
+void print_battery_info(int number, const char *path, const char *format, bool last_full_capacity);
void print_time(const char *format, struct tm *current_tm);
void print_ddate(const char *format, struct tm *current_tm);
const char *get_ip_addr();
battery 0 {
format = "%status %percentage %remaining"
+ path = "/sys/class/power_supply/BAT%d/uevent"
}
run_watch DHCP {
want to see it this way, because it tells me how worn off my battery is.),
just specify +last_full_capacity = true+.
+If your battery is represented in a non-standard path in /sys, be sure to
+modify the "path" property accordingly. The first occurence of %d gets replaced
+with the battery number, but you can just hard-code a path as well.
+
*Example order*: +battery 0+
*Example format*: +%status %remaining+
* worn off your battery is.
*
*/
-void print_battery_info(int number, const char *format, bool last_full_capacity) {
+void print_battery_info(int number, const char *path, const char *format, bool last_full_capacity) {
time_t empty_time;
struct tm *empty_tm;
char buf[1024];
#if defined(LINUX)
static char batpath[512];
- sprintf(batpath, "/sys/class/power_supply/BAT%d/uevent", number);
+ sprintf(batpath, path, number);
if (!slurp(batpath, buf, sizeof(buf))) {
printf("No battery");
return;