diff --git a/i3status.c b/i3status.c index 0e35eab..c9ded2f 100644 --- a/i3status.c +++ b/i3status.c @@ -71,6 +71,7 @@ int main(int argc, char *argv[]) { cfg_opt_t battery_opts[] = { CFG_STR("format", "%status %remaining", CFGF_NONE), + CFG_BOOL("last_full_capacity", false, CFGF_NONE), CFG_END() }; @@ -157,7 +158,7 @@ int main(int argc, char *argv[]) { 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")); + print_battery_info(atoi(title), 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")); diff --git a/i3status.h b/i3status.h index 3fa9644..1926021 100644 --- a/i3status.h +++ b/i3status.h @@ -63,7 +63,7 @@ char *endcolor() __attribute__ ((pure)); void print_ipv6_info(const char *format); void print_disk_info(const char *path, const char *format); -void print_battery_info(int number, const char *format); +void print_battery_info(int number, const char *format, bool last_full_capacity); void print_time(const char *format); const char *get_ip_addr(); void print_wireless_info(const char *interface, const char *format_up, const char *format_down); diff --git a/man/i3status.man b/man/i3status.man index d73c6cc..eb16bf6 100644 --- a/man/i3status.man +++ b/man/i3status.man @@ -145,7 +145,11 @@ interface. Getting the link speed requires root privileges. === Battery Gets the status (charging, discharging, running), percentage and remaining -time of the given battery. +time of the given battery. If you want to use the last full capacity instead +of the design capacity (when using the design capacity, it may happen that +your battery is at 23% when fully charged because it’s old. In general, I +want to see it this way, because it tells me how worn off my battery is.), +just specify +last_full_capacity = true+. *Example order*: +battery 0+ diff --git a/src/print_battery_info.c b/src/print_battery_info.c index eb1f6bb..4685d52 100644 --- a/src/print_battery_info.c +++ b/src/print_battery_info.c @@ -16,7 +16,7 @@ * worn off your battery is. * */ -void print_battery_info(int number, const char *format) { +void print_battery_info(int number, const char *format, bool last_full_capacity) { char buf[1024]; char *walk, *last; int full_design = -1, @@ -52,17 +52,15 @@ void print_battery_info(int number, const char *format) { status = CS_FULL; else { /* The only thing left is the full capacity */ -#if 0 - if (bat->use_last_full) { + if (last_full_capacity) { if (!BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL") && !BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL")) continue; } else { -#endif if (!BEGINS_WITH(last, "POWER_SUPPLY_CHARGE_FULL_DESIGN") && !BEGINS_WITH(last, "POWER_SUPPLY_ENERGY_FULL_DESIGN")) continue; - //} + } full_design = atoi(walk+1); }