cfg_opt_t battery_opts[] = {
CFG_STR("format", "%status %remaining", 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"));
+ 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"));
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);
=== 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+
* 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,
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);
}