diff options
| author | Richard M. Stallman | 2006-01-19 17:49:13 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2006-01-19 17:49:13 +0000 |
| commit | d0600240da7152e8847e1e5f8aeb5b38cb197074 (patch) | |
| tree | c6237a2414b323b79f246d88009be684af1bd9dd | |
| parent | 964a8b47277fdf11eff203659d9aa6b11a372c5c (diff) | |
| download | emacs-d0600240da7152e8847e1e5f8aeb5b38cb197074.tar.gz emacs-d0600240da7152e8847e1e5f8aeb5b38cb197074.zip | |
(battery-linux-proc-acpi): Handle "last full capacity".
| -rw-r--r-- | lisp/battery.el | 17 |
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: | |||
| 271 | %h Remaining time in hours | 271 | %h Remaining time in hours |
| 272 | %t Remaining time in the form `h:min'" | 272 | %t Remaining time in the form `h:min'" |
| 273 | (let ((design-capacity 0) | 273 | (let ((design-capacity 0) |
| 274 | (last-full-capacity 0) | ||
| 275 | full-capacity | ||
| 274 | (warn 0) | 276 | (warn 0) |
| 275 | (low 0) | 277 | (low 0) |
| 276 | capacity rate rate-type charging-state minutes hours) | 278 | capacity rate rate-type charging-state minutes hours) |
| @@ -310,18 +312,25 @@ The following %-sequences are provided: | |||
| 310 | (when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$" | 312 | (when (re-search-forward "design capacity: +\\([0-9]+\\) m[AW]h$" |
| 311 | nil t) | 313 | nil t) |
| 312 | (incf design-capacity (string-to-number (match-string 1)))) | 314 | (incf design-capacity (string-to-number (match-string 1)))) |
| 315 | (when (re-search-forward "last full capacity: +\\([0-9]+\\) m[AW]h$" | ||
| 316 | nil t) | ||
| 317 | (incf last-full-capacity (string-to-number (match-string 1)))) | ||
| 313 | (when (re-search-forward | 318 | (when (re-search-forward |
| 314 | "design capacity warning: +\\([0-9]+\\) m[AW]h$" nil t) | 319 | "design capacity warning: +\\([0-9]+\\) m[AW]h$" nil t) |
| 315 | (incf warn (string-to-number (match-string 1)))) | 320 | (incf warn (string-to-number (match-string 1)))) |
| 316 | (when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$" | 321 | (when (re-search-forward "design capacity low: +\\([0-9]+\\) m[AW]h$" |
| 317 | nil t) | 322 | nil t) |
| 318 | (incf low (string-to-number (match-string 1))))))) | 323 | (incf low (string-to-number (match-string 1))))))) |
| 324 | (setq full-capacity (if (> last-full-capacity 0) | ||
| 325 | last-full-capacity design-capacity)) | ||
| 319 | (and capacity rate | 326 | (and capacity rate |
| 320 | (setq minutes (if (zerop rate) 0 | 327 | (setq minutes (if (zerop rate) 0 |
| 321 | (floor (* (/ (float (if (string= charging-state | 328 | (floor (* (/ (float (if (string= charging-state |
| 322 | "charging") | 329 | "charging") |
| 323 | (- design-capacity capacity) | 330 | (- full-capacity capacity) |
| 324 | capacity)) rate) 60))) | 331 | capacity)) |
| 332 | rate) | ||
| 333 | 60))) | ||
| 325 | hours (/ minutes 60))) | 334 | hours (/ minutes 60))) |
| 326 | (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A")) | 335 | (list (cons ?c (or (and capacity (number-to-string capacity)) "N/A")) |
| 327 | (cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state") | 336 | (cons ?L (or (when (file-exists-p "/proc/acpi/ac_adapter/AC/state") |
| @@ -368,10 +377,10 @@ The following %-sequences are provided: | |||
| 368 | (cons ?t (or (and minutes | 377 | (cons ?t (or (and minutes |
| 369 | (format "%d:%02d" hours (- minutes (* 60 hours)))) | 378 | (format "%d:%02d" hours (- minutes (* 60 hours)))) |
| 370 | "N/A")) | 379 | "N/A")) |
| 371 | (cons ?p (or (and design-capacity capacity | 380 | (cons ?p (or (and full-capacity capacity |
| 372 | (number-to-string | 381 | (number-to-string |
| 373 | (floor (/ capacity | 382 | (floor (/ capacity |
| 374 | (/ (float design-capacity) 100))))) | 383 | (/ (float full-capacity) 100))))) |
| 375 | "N/A"))))) | 384 | "N/A"))))) |
| 376 | 385 | ||
| 377 | 386 | ||