Sync to HEAD
[bpt/emacs.git] / lisp / battery.el
CommitLineData
e8af40ee 1;;; battery.el --- display battery status information
6b279740 2
6b61353c 3;; Copyright (C) 1997, 1998, 2000, 2001, 2003 Free Software Foundation, Inc.
6b279740 4
3b361901 5;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org>
d5323ba0 6;; Keywords: hardware
6b279740 7
f12b0b96 8;; This file is part of GNU Emacs.
6b279740 9
f12b0b96 10;; GNU Emacs is free software; you can redistribute it and/or modify
6b279740
RS
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
f12b0b96 15;; GNU Emacs is distributed in the hope that it will be useful,
6b279740
RS
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
f12b0b96
RS
21;; along with GNU Emacs; see the file COPYING. If not, write to the
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6b279740
RS
23;; Boston, MA 02111-1307, USA.
24
25;;; Commentary:
26
6b61353c
KH
27;; There is at present support for interpreting the new `/proc/apm'
28;; file format of Linux version 1.3.58 or newer and for the `/proc/acpi/'
29;; directory structure of Linux 2.4.20 and 2.6.
6b279740
RS
30
31;;; Code:
32
33(require 'timer)
34
35\f
4bef9110
SE
36
37(defgroup battery nil
38 "Display battery status information."
39 :prefix "battery-"
40 :group 'hardware)
41
42(defcustom battery-status-function
6b279740
RS
43 (cond ((and (eq system-type 'gnu/linux)
44 (file-readable-p "/proc/apm"))
6b61353c
KH
45 'battery-linux-proc-apm)
46 ((and (eq system-type 'gnu/linux)
47 (file-directory-p "/proc/acpi/battery"))
48 'battery-linux-proc-acpi))
6b279740 49 "*Function for getting battery status information.
681e6b4b
DL
50The function has to return an alist of conversion definitions.
51Its cons cells are of the form
6b279740
RS
52
53 (CONVERSION . REPLACEMENT-TEXT)
54
55CONVERSION is the character code of a \"conversion specification\"
4bef9110 56introduced by a `%' character in a control string."
681e6b4b 57 :type '(choice (const nil) function)
4bef9110 58 :group 'battery)
6b279740 59
4bef9110 60(defcustom battery-echo-area-format
6b279740 61 (cond ((eq battery-status-function 'battery-linux-proc-apm)
6b61353c
KH
62 "Power %L, battery %B (%p%% load, remaining time %t)")
63 ((eq battery-status-function 'battery-linux-proc-acpi)
64 "Power %L, battery %B at %r mA (%p%% load, remaining time %t)"))
6b279740
RS
65 "*Control string formatting the string to display in the echo area.
66Ordinary characters in the control string are printed as-is, while
67conversion specifications introduced by a `%' character in the control
68string are substituted as defined by the current value of the variable
4bef9110
SE
69`battery-status-function'."
70 :type '(choice string (const nil))
71 :group 'battery)
6b279740
RS
72
73(defvar battery-mode-line-string nil
74 "String to display in the mode line.")
75
4bef9110 76(defcustom battery-mode-line-format
6b279740 77 (cond ((eq battery-status-function 'battery-linux-proc-apm)
6b61353c
KH
78 " [%b%p%%]")
79 ((eq battery-status-function 'battery-linux-proc-acpi)
80