aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJérémy Compostella2011-12-21 07:20:40 -0500
committerStefan Monnier2011-12-21 07:20:40 -0500
commit728a1f2bbbf6af5166f52af7fefac72fa83b495c (patch)
tree1610b9f06356ec44369b52e455f141f9e1ce9620 /lisp
parent0d373f73bcaf14863b186b74d6e80a5209e2720c (diff)
downloademacs-728a1f2bbbf6af5166f52af7fefac72fa83b495c.tar.gz
emacs-728a1f2bbbf6af5166f52af7fefac72fa83b495c.zip
* lisp/battery.el (battery-linux-sysfs): Add missing parameters from acpi.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/battery.el35
2 files changed, 36 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index bc5764e3666..cf029ddb03e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12011-12-21 Jérémy Compostella <jeremy.compostella@gmail.com>
2
3 * battery.el (battery-linux-sysfs): Add missing parameters from acpi.
4
12011-12-21 Teodor Zlatanov <tzz@lifelogs.com> 52011-12-21 Teodor Zlatanov <tzz@lifelogs.com>
2 6
3 * progmodes/cfengine.el: Add Version. 7 * progmodes/cfengine.el: Add Version.
diff --git a/lisp/battery.el b/lisp/battery.el
index 3b245ed644d..bb899f2beae 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -421,10 +421,15 @@ format introduced in Linux version 2.4.25.
421 421
422The following %-sequences are provided: 422The following %-sequences are provided:
423%c Current capacity (mAh or mWh) 423%c Current capacity (mAh or mWh)
424%r Current rate
424%B Battery status (verbose) 425%B Battery status (verbose)
426%d Temperature (in degrees Celsius)
425%p Battery load percentage 427%p Battery load percentage
426%L AC line status (verbose)" 428%L AC line status (verbose)
427 (let (charging-state 429%m Remaining time (to charge or discharge) in minutes
430%h Remaining time (to charge or discharge) in hours
431%t Remaining time (to charge or discharge) in the form `h:min'"
432 (let (charging-state rate temperature hours
428 (charge-full 0.0) 433 (charge-full 0.0)
429 (charge-now 0.0) 434 (charge-now 0.0)
430 (energy-full 0.0) 435 (energy-full 0.0)
@@ -444,6 +449,12 @@ The following %-sequences are provided:
444 (and (re-search-forward "POWER_SUPPLY_STATUS=\\(.*\\)$" nil t) 449 (and (re-search-forward "POWER_SUPPLY_STATUS=\\(.*\\)$" nil t)
445 (member charging-state '("Unknown" "Full" nil)) 450 (member charging-state '("Unknown" "Full" nil))
446 (setq charging-state (match-string 1))) 451 (setq charging-state (match-string 1)))
452 (when (re-search-forward
453 "POWER_SUPPLY_\\(CURRENT\\|POWER\\)_NOW=\\([0-9]*\\)$"
454 nil t)
455 (setq rate (float (string-to-number (match-string 2)))))
456 (when (re-search-forward "POWER_SUPPLY_TEMP=\\([0-9]*\\)$" nil t)
457 (setq temperature (match-string 1)))
447 (let (full-string now-string) 458 (let (full-string now-string)
448 ;; Sysfs may list either charge (mAh) or energy (mWh). 459 ;; Sysfs may list either charge (mAh) or energy (mWh).
449 ;; Keep track of both, and choose which to report later. 460 ;; Keep track of both, and choose which to report later.
@@ -466,12 +477,30 @@ The following %-sequences are provided:
466 (setq energy-full (+ energy-full 477 (setq energy-full (+ energy-full
467 (string-to-number full-string)) 478 (string-to-number full-string))
468 energy-now (+ energy-now 479 energy-now (+ energy-now
469 (string-to-number now-string))))))))) 480 (string-to-number now-string))))))
481 (goto-char (point-min))
482 (when (and energy-now rate (not (zerop rate))
483 (re-search-forward
484 "POWER_SUPPLY_VOLTAGE_NOW=\\([0-9]*\\)$" nil t))
485 (let ((remaining (if (string= charging-state "Discharging")
486 energy-now
487 (- energy-full energy-now))))
488 (setq hours (/ (/ (* remaining (string-to-number
489 (match-string 1)))
490 rate)
491 10000000.0)))))))
470 (list (cons ?c (cond ((or (> charge-full 0) (> charge-now 0)) 492 (list (cons ?c (cond ((or (> charge-full 0) (> charge-now 0))
471 (number-to-string charge-now)) 493 (number-to-string charge-now))
472 ((or (> energy-full 0) (> energy-now 0)) 494 ((or (> energy-full 0) (> energy-now 0))
473 (number-to-string energy-now)) 495 (number-to-string energy-now))
474 (t "N/A"))) 496 (t "N/A")))
497 (cons ?r (if rate (format "%.1f" (/ rate 1000000.0)) "N/A"))
498 (cons ?m (if hours (format "%d" (* hours 60)) "N/A"))
499 (cons ?h (if hours (format "%d" hours) "N/A"))
500 (cons ?t (if hours
501 (format "%d:%02d" hours (* (- hours (floor hours)) 60))
502 "N/A"))
503 (cons ?d (or temperature "N/A"))
475 (cons ?B (or charging-state "N/A")) 504 (cons ?B (or charging-state "N/A"))
476 (cons ?p (cond ((> charge-full 0) 505 (cons ?p (cond ((> charge-full 0)
477 (format "%.1f" 506 (format "%.1f"