Subject: battery.el does not display remaining time when using sysfs

From: Dan Nicolaescu <[email-masked]>
Date: Wed, 18 Apr 2012 02:37:21 -0400

After a kernel upgrade battery.el on a machine started using the sysfs
backend instead of the acpi backend.

That info displayed by default now is not very useful because it does
not include "remaining time" like all the other backends do. 
I think this might be considered a regression, the display was more
useful in the previous version than it is now.

Here's a fix for that, and fix for the charge in a system with 2
batteries, when one of them is not in use.
Please check this in the appropriate place.

       * battery.el (battery-echo-area-format): Display remaining time
       for the sysfs backend too.
       (battery-linux-sysfs): Fix conditional for the charge.

=== modified file 'lisp/battery.el'
--- lisp/battery.el	2012-04-12 02:04:29 +0000
+++ lisp/battery.el	2012-04-16 16:29:43 +0000
@@ -78,7 +78,7 @@ introduced by a `%' character in a contr
   (cond ((eq battery-status-function 'battery-linux-proc-acpi)
 	 "Power %L, battery %B at %r (%p%% load, remaining time %t)")
 	((eq battery-status-function 'battery-linux-sysfs)
-	 "Power %L, battery %B (%p%% load)")
+	 "Power %L, battery %B (%p%% load, remaining time %t)")
 	((eq battery-status-function 'battery-pmset)
 	 "%L power, battery %B (%p%% load, remaining time %t)")
 	(battery-status-function
@@ -509,7 +509,7 @@ The following %-sequences are provided:
 		     "N/A"))
 	  (cons ?d (or temperature "N/A"))
 	  (cons ?B (or charging-state "N/A"))
-	  (cons ?p (cond ((> charge-full 0)
+	  (cons ?p (cond ((and (> charge-full 0) (> charge-now 0))
 			  (format "%.1f"
 				  (/ (* 100 charge-now) charge-full)))
 			 ((> energy-full 0)