1 |
;;; battery.el --- display battery status information |
;;; battery.el --- display battery status information |
2 |
|
|
3 |
;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004 |
;; Copyright (C) 1997, 1998, 2000, 2001, 2003, 2004, 2005 |
4 |
;; Free Software Foundation, Inc. |
;; Free Software Foundation, Inc. |
5 |
|
|
6 |
;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org> |
;; Author: Ralph Schleicher <rs@nunatak.allgaeu.org> |
108 |
"Battery status not available"))) |
"Battery status not available"))) |
109 |
|
|
110 |
;;;###autoload |
;;;###autoload |
111 |
(defun display-battery () |
(define-minor-mode display-battery-mode |
112 |
"Display battery status information in the mode line. |
"Display battery status information in the mode line. |
113 |
The text being displayed in the mode line is controlled by the variables |
The text being displayed in the mode line is controlled by the variables |
114 |
`battery-mode-line-format' and `battery-status-function'. |
`battery-mode-line-format' and `battery-status-function'. |
115 |
The mode line will be updated automatically every `battery-update-interval' |
The mode line will be updated automatically every `battery-update-interval' |
116 |
seconds." |
seconds." |
117 |
(interactive) |
:global t |
118 |
(setq battery-mode-line-string "") |
(setq battery-mode-line-string "") |
119 |
(or global-mode-string (setq global-mode-string '(""))) |
(or global-mode-string (setq global-mode-string '(""))) |
|
(add-to-list 'global-mode-string 'battery-mode-line-string t) |
|
120 |
(and battery-update-timer (cancel-timer battery-update-timer)) |
(and battery-update-timer (cancel-timer battery-update-timer)) |
121 |
(setq battery-update-timer (run-at-time nil battery-update-interval |
(if (not display-battery-mode) |
122 |
'battery-update-handler)) |
(setq global-mode-string |
123 |
(battery-update)) |
(delq 'battery-mode-line-string global-mode-string)) |
124 |
|
(add-to-list 'global-mode-string 'battery-mode-line-string t) |
125 |
|
(setq battery-update-timer (run-at-time nil battery-update-interval |
126 |
|
'battery-update-handler)) |
127 |
|
(battery-update))) |
128 |
|
|
129 |
(defun battery-update-handler () |
(defun battery-update-handler () |
130 |
(battery-update) |
(battery-update) |