diff options
author | Richard M. Stallman <rms@gnu.org> | 2011-06-27 04:04:55 -0400 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2011-06-27 04:04:55 -0400 |
commit | 43d5bf84cf4f81bc11045971f34cc2b51fa06b03 (patch) | |
tree | 07cc08174b1bd90df34dfa0ebd26dc88ea3edd24 /lisp/battery.el | |
parent | d31fd9acf0992922c3e9d80eae7c6a74529623ab (diff) | |
download | emacs-43d5bf84cf4f81bc11045971f34cc2b51fa06b03.tar.gz |
Implement battery-mode-line-limit option.
Diffstat (limited to 'lisp/battery.el')
-rw-r--r-- | lisp/battery.el | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/battery.el b/lisp/battery.el index 9afe9de7b98..d7d3045fa58 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -102,6 +102,11 @@ string are substituted as defined by the current value of the variable "String to display in the mode line.") ;;;###autoload (put 'battery-mode-line-string 'risky-local-variable t) +(defcustom battery-mode-line-limit 100 + "Percentage of full battery load below which display battery status" + :type 'integer + :group 'battery) + (defcustom battery-mode-line-format (cond ((eq battery-status-function 'battery-linux-proc-acpi) "[%b%p%%,%d°C]") @@ -182,16 +187,21 @@ seconds." (defun battery-update () "Update battery status information in the mode line." - (setq battery-mode-line-string - (propertize (if (and battery-mode-line-format - battery-status-function) - (battery-format - battery-mode-line-format - (funcall battery-status-function)) - "") - 'help-echo "Battery status information")) + (let ((data (and battery-status-function (funcall battery-status-function)))) + (setq battery-mode-line-string + (propertize (if (and battery-mode-line-format + (<= (car (read-from-string (cdr (assq ?p data)))) + battery-mode-line-limit)) + (battery-format + battery-mode-line-format + data) + "") + 'face + (and (<= (car (read-from-string (cdr (assq ?p data)))) + battery-load-critical) + 'font-lock-warning-face) + 'help-echo "Battery status information"))) (force-mode-line-update)) - ;;; `/proc/apm' interface for Linux. |