Difference between revisions of "Battery"

From WikEmacs
Jump to navigation Jump to search
(Created page with "If you are using Emacs on a notebook computer you might want to add your battery status to the modeline. Invoking <code>display-battery-mode</code> will do this. Alternat...")
 
m
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
If you are using Emacs on a notebook computer you might want to add your battery status to the [[modeline]]. Invoking <code>display-battery-mode</code> will do this.
+
{{Package
 +
|name=Battery.el
 +
|author = [[Ralph Schleicher]]
 +
|description=Shows the battery status in the [[mode line]]
 +
|source=http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/battery.el
 +
|maintainer=[[FSF]]
 +
|in_emacs=yes
 +
|Development status=active
 +
}}
  
Alternatively, if you just wish to output your current battery information to the [[minibuffer]] and your <tt>*Messages*</tt> buffer you can run <code>M-x battery</code>.
+
== Basic setup ==
 +
 
 +
; {{Command|display-battery-mode}}
 +
: Add your battery status to the [[Modeline]]
 +
 
 +
; {{Command|battery}}
 +
: View battery status
 +
 
 +
== Customization ==
 +
===Gnu/Linux ===
 +
==== How to show battery status only on laptop? ====
 +
if a device has no battery, we don't want to '''display-battery-mode''' be
 +
enabled.<ref>http://stackoverflow.com/questions/5562974/emacs-is-it-running-on-laptop-or-on-desktop</ref>
 +
 
 +
<source lang="lisp">
 +
(require 'battery)
 +
(when (and battery-status-function
 +
          (not (string-match-p "N/A"
 +
                                (battery-format "%B"
 +
                                                (funcall battery-status-function)))))
 +
  (display-battery-mode 1))
 +
</source>
 +
 
 +
== See Also ==
 +
[[time]]
 +
 
 +
[[Category:Desktop Management]]
 +
[[Category:Appearance]]

Latest revision as of 07:02, 5 April 2012

Battery.el
Description Shows the battery status in the mode line
Author Ralph Schleicher
Maintainer FSF
Source http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/battery.el
Part of Emacs yes

Basic setup

M-x display-battery-mode
Add your battery status to the Modeline
M-x battery
View battery status

Customization

Gnu/Linux

How to show battery status only on laptop?

if a device has no battery, we don't want to display-battery-mode be enabled.<ref>http://stackoverflow.com/questions/5562974/emacs-is-it-running-on-laptop-or-on-desktop</ref>

(require 'battery)
(when (and battery-status-function
           (not (string-match-p "N/A"
                                (battery-format "%B"
                                                (funcall battery-status-function)))))
  (display-battery-mode 1))

See Also

time