summaryrefslogtreecommitdiff
path: root/lisp/battery.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2006-01-19 17:49:13 +0000
committerRichard M. Stallman <rms@gnu.org>2006-01-19 17:49:13 +0000
commitd0600240da7152e8847e1e5f8aeb5b38cb197074 (patch)
treec6237a2414b323b79f246d88009be684af1bd9dd /lisp/battery.el
parent964a8b47277fdf11eff203659d9aa6b11a372c5c (diff)
downloademacs-d0600240da7152e8847e1e5f8aeb5b38cb197074.tar.gz
(battery-linux-proc-acpi): Handle "last full capacity".
Diffstat (limited to 'lisp/battery.el')
-rw-r--r--lisp/battery.el17
1 files changed, 13 insertions, 4 deletions
diff --git a/lisp/battery.el b/lisp/battery.el
index 710be5a4220..54a0e207ffc 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -271,6 +271,8 @@ The following %-sequences are provided:
%h Remaining time in hours
%t Remaining time in the form `h:min'"
(let ((design-capacity 0)
+ (last-full-capacity 0)
+ full-capacity
(warn 0)
(low 0)
capacity rate rate-type charging-state minutes hours)
@@ -310,18 +312,25 @@ The following %-sequences are provided:
(when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$"
nil t)
(incf design-capacity (string-to-number (match-string 1))))
+ (when (re-search-forward "last full capacity: +\\([0-9]+\\) m[AW]h$"
+ nil t)
+ (incf last-full-capacity (string-to-number (match-string 1))))
(when (re-search-forward
"design capacity warning: +\\([0-9]+\\) m[AW]h$" nil t)
(incf warn (string-to-number (match-string 1))))
(when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$"
nil t)
(incf low (string-to-number (match-string 1)))))))
+ (setq full-capacity (if (> last-full-capacity 0)
+ last-full-capacity design-capacity))
(and capacity rate
(setq minutes (if (zerop rate) 0
(floor (* (/ (float (if (string= charging-state
"charging")
- (- design-capacity capacity)
- capacity)) rate) 60)))
+ (- full-capacity capacity)
+ capacity))
+ rate)
+ 60)))
hours (/ minutes 60)))
(list (cons ?c (or (and capacity (number-to-string capacity)) "N/A"))
(cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state")
@@ -368,10 +377,10 @@ The following %-sequences are provided:
(cons ?t (or (and minutes
(format "%d:%02d" hours (- minutes (* 60 hours))))
"N/A"))
- (cons ?p (or (and design-capacity capacity
+ (cons ?p (or (and full-capacity capacity
(number-to-string
(floor (/ capacity
- (/ (float design-capacity) 100)))))
+ (/ (float full-capacity) 100)))))
"N/A")))))