Function: battery-haiku-acpi-battery
battery-haiku-acpi-battery is a byte-compiled function defined in
battery.el.gz.
Signature
(battery-haiku-acpi-battery)
Documentation
Get battery status from /dev/power/acpi_battery.
This function only works on Haiku systems with an ACPI battery.
The following %-sequences are provided:
%c Current capacity (mAh)
%r Current rate of charge or discharge
%L AC line status (verbose)
%B Battery status (verbose)
%b Battery status: empty means high, - means low,
! means critical, and + means charging
%p Battery load percentage
Source Code
;; Defined in /usr/src/emacs/lisp/battery.el.gz
(defun battery-haiku-acpi-battery ()
"Get battery status from `/dev/power/acpi_battery'.
This function only works on Haiku systems with an ACPI battery.
The following %-sequences are provided:
%c Current capacity (mAh)
%r Current rate of charge or discharge
%L AC line status (verbose)
%B Battery status (verbose)
%b Battery status: empty means high, `-' means low,
`!' means critical, and `+' means charging
%p Battery load percentage"
(with-temp-buffer
(dolist (file (battery--files "/dev/power/acpi_battery"))
(insert-file-contents (expand-file-name file "/dev/power/acpi_battery")))
;; I don't think Haiku actually supports multiple batteries yet,
;; since the code in PowerStatus doesn't take care of that
;; situation.
(let ((list (ignore-errors (battery--search-haiku-acpi-status))))
(if list
(list (cons ?c (format "%.0f" (plist-get list :capacity)))
(cons ?r (format "%.0f" (plist-get list :rate)))
(cons ?B (symbol-name (plist-get list :state)))
(cons ?b (let ((state (plist-get list :state)))
(cond
((eq state 'charging) "+")
((and (eq state 'discharging)
(< (/ (plist-get list :capacity)
(plist-get list :last-full-charge))
0.15))
"-")
((eq state 'critical) "!")
(t ""))))
(cons ?L (if (not (eq (plist-get list :state) 'discharging))
"on-line" "off-line"))
(cons ?p (format "%.0f"
(* 100 (/ (plist-get list :capacity)
(plist-get list :last-full-charge))))))
'((?c . "N/A")
(?r . "N/A")
(?B . "N/A")
(?b . "N/A")
(?p . "N/A"))))))