summaryrefslogtreecommitdiff
path: root/lisp/battery.el
diff options
context:
space:
mode:
authorJason Rumney <jasonr@gnu.org>2008-04-29 00:59:37 +0000
committerJason Rumney <jasonr@gnu.org>2008-04-29 00:59:37 +0000
commit20d4381e4b811eeb3f28e15157d9a31eb7e48421 (patch)
tree950c4bda6e190945c22e8c89c8f5693d44427dbb /lisp/battery.el
parent2c2279c6c2af2c8b9c8b36d5af484d99d4d3c183 (diff)
downloademacs-20d4381e4b811eeb3f28e15157d9a31eb7e48421.tar.gz
(battery-status-function): Use w32-battery-status on Windows.
(battery-echo-area-format): Make apm format the general case. (battery-mode-line-format): Merge apm and pmset formats as the general case.
Diffstat (limited to 'lisp/battery.el')
-rw-r--r--lisp/battery.el27
1 files changed, 14 insertions, 13 deletions
diff --git a/lisp/battery.el b/lisp/battery.el
index 0fff947fc76..2123feb0c5b 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -25,10 +25,11 @@
;;; Commentary:
-;; There is at present support for GNU/Linux and OS X. This library
-;; supports both the `/proc/apm' file format of Linux version 1.3.58
-;; or newer and the `/proc/acpi/' directory structure of Linux 2.4.20
-;; and 2.6. Darwin (OS X) is supported by using the `pmset' program.
+;; There is at present support for GNU/Linux, OS X and Windows. This
+;; library supports both the `/proc/apm' file format of Linux version
+;; 1.3.58 or newer and the `/proc/acpi/' directory structure of Linux
+;; 2.4.20 and 2.6. Darwin (OS X) is supported by using the `pmset'
+;; program. Windows is supported by the GetSystemPowerStatus API call.
;;; Code:
@@ -54,7 +55,9 @@
(and (eq (call-process "pmset" nil t nil "-g" "ps") 0)
(> (buffer-size) 0)))
(error nil)))
- 'battery-pmset))
+ 'battery-pmset)
+ ((eq system-type 'windows-nt)
+ 'w32-battery-status))
"*Function for getting battery status information.
The function has to return an alist of conversion definitions.
Its cons cells are of the form
@@ -67,12 +70,12 @@ introduced by a `%' character in a control string."
:group 'battery)
(defcustom battery-echo-area-format
- (cond ((eq battery-status-function 'battery-linux-proc-apm)
- "Power %L, battery %B (%p%% load, remaining time %t)")
- ((eq battery-status-function 'battery-linux-proc-acpi)
+ (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-pmset)
- "%L power, battery %B (%p%% load, remaining time %t)"))
+ "%L power, battery %B (%p%% load, remaining time %t)")
+ (battery-status-function
+ "Power %L, battery %B (%p%% load, remaining time %t)"))
"*Control string formatting the string to display in the echo area.
Ordinary characters in the control string are printed as-is, while
conversion specifications introduced by a `%' character in the control
@@ -97,11 +100,9 @@ string are substituted as defined by the current value of the variable
;;;###autoload (put 'battery-mode-line-string 'risky-local-variable t)
(defcustom battery-mode-line-format
- (cond ((eq battery-status-function 'battery-linux-proc-apm)
- "[%b%p%%]")
- ((eq battery-status-function 'battery-linux-proc-acpi)
+ (cond ((eq battery-status-function 'battery-linux-proc-acpi)
"[%b%p%%,%d°C]")
- ((eq battery-status-function 'battery-pmset)
+ (battery-status-function
"[%b%p%%]"))
"*Control string formatting the string to display in the mode line.
Ordinary characters in the control string are printed as-is, while