-;;; battery.el --- display battery status information
+;;; battery.el --- display battery status information -*- coding: iso-8859-1 -*-
;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006 Free Software Foundation, Inc.
+;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
;; Keywords: hardware
;; This file is part of GNU Emacs.
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; 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:
(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
: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
;;;###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