Variable: battery-status-function

battery-status-function is a customizable variable defined in battery.el.gz.

Value

nil

Documentation

Function for getting battery status information.

The function has to return an alist of conversion definitions. Its cons cells are of the form

    (CONVERSION . REPLACEMENT-TEXT)

CONVERSION is the character code of a "conversion specification" introduced by a % character in a control string. See the documentation of battery-echo-area-format for supported conversion specifications and the format used by battery to show battery status in the echo area.

The default value of the function is determined at startup, and depends on the battery-related services available on the system.

This variable was added, or its default value changed, in Emacs 28.1.

Probably introduced at or before Emacs version 28.1.

Source Code

;; Defined in /usr/src/emacs/lisp/battery.el.gz
(defcustom battery-status-function
  (cond ((member battery-upower-service (dbus-list-activatable-names))
         #'battery-upower)
        ((and (eq system-type 'gnu/linux)
              (file-readable-p "/sys/")
              (battery--find-linux-sysfs-batteries))
         #'battery-linux-sysfs)
	((and (eq system-type 'gnu/linux)
	      (file-directory-p "/proc/acpi/battery"))
	 #'battery-linux-proc-acpi)
	((and (eq system-type 'gnu/linux)
              (file-readable-p "/proc/")
              (file-readable-p "/proc/apm"))
         #'battery-linux-proc-apm)
        ;; Now try the Android battery status function.
        ;; Note that even though the Linux kernel APIs are sometimes
        ;; available on Android, they are badly implemented by Android
        ;; kernels, so avoid using those.
        ((fboundp 'android-query-battery)
         #'battery-android)
	((and (eq system-type 'berkeley-unix)
	      (file-executable-p "/usr/sbin/apm"))
	 #'battery-bsd-apm)
	((and (eq system-type 'darwin)
              (ignore-errors
                (with-temp-buffer
                  (and (eq (call-process "pmset" nil t nil "-g" "ps") 0)
                       (not (bobp))))))
	 #'battery-pmset)
        ((and (eq system-type 'haiku)
              ;; TODO: Support the Haiku APM battery driver.
              (file-directory-p "/dev/power/acpi_battery"))
         #'battery-haiku-acpi-battery)
	((fboundp 'w32-battery-status)
	 #'w32-battery-status))
  "Function for getting battery status information.
The function has to return an alist of conversion definitions.
Its cons cells are of the form

    (CONVERSION . REPLACEMENT-TEXT)

CONVERSION is the character code of a \"conversion specification\"
introduced by a `%' character in a control string.  See the
documentation of `battery-echo-area-format' for supported conversion
specifications and the format used by `battery' to show battery
status in the echo area.

The default value of the function is determined at startup, and depends
on the battery-related services available on the system."
  :version "28.1"
  :type '(choice (const nil) function))