unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@gnu.org>
To: 11269@debbugs.gnu.org
Subject: bug#11269: battery.el does not display remaining time when using sysfs
Date: Wed, 18 Apr 2012 02:37:21 -0400	[thread overview]
Message-ID: <yxqliltmtpa.fsf@fencepost.gnu.org> (raw)


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)







             reply	other threads:[~2012-04-18  6:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-18  6:37 Dan Nicolaescu [this message]
2012-04-20  7:32 ` bug#11269: battery.el does not display remaining time when using sysfs Chong Yidong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yxqliltmtpa.fsf@fencepost.gnu.org \
    --to=dann@gnu.org \
    --cc=11269@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).