]> git.sur5r.net Git - i3/i3status/commitdiff
Implement option to use the last full capacity instead of the design capacity
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 16 Oct 2009 18:37:41 +0000 (20:37 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 16 Oct 2009 18:37:41 +0000 (20:37 +0200)
i3status.c
i3status.h
man/i3status.man
src/print_battery_info.c

index 0e35eabed2a7d34b7485f77b4bcd4d801e63eaec..c9ded2f9b2043df71cb9a37bd5778a26fe352fb1 100644 (file)
@@ -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"));
index 3fa964434b52b9420e780f82da13c52148c85ab5..19260217eda422c29da5123776e051b23b2ec7e9 100644 (file)
@@ -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);
index d73c6cc3edb3c8329cbe115c4c78f4424e527530..eb16bf6434628fa1affead33204da0e0c01fe5b5 100644 (file)
@@ -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+
 
index eb1f6bb2fb49f5aa9fff6cd51cc0a33640acc2d0..4685d52afc2a89d00a40ff72a887e38644f35f08 100644 (file)
@@ -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);
                 }