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