+(defun ff/battery-discharging (l)
+ (and l (or (string= (ff/file-first-line (concat (car l) "/status")) "Discharging")
+ (ff/battery-discharging (cdr l)))))
+
+;; If there is one "Discharging" among the states of all the
+;; batteries, the global state is 'discharging. Otherwise, if there is
+;; a "Charging", the state is 'charging. If none is true, it is
+;; 'unknown
+(defun ff/battery-state (l)
+ (if l
+ (let ((u (ff/file-first-line (concat (car l) "/status"))))
+ (if (string= u "Discharging") 'discharging
+ (let ((s (ff/battery-state (cdr l))))
+ (if (eq s 'discharging) 'discharging
+ (if (or (eq s 'charging) (string= u "Charging"))
+ 'charging
+ 'unknown))
+ )
+ )
+ )
+ 'unknown))
+
+(defun ff/sum-numbers (list-files prefix)
+ (apply '+
+ (mapcar
+ (lambda (f) (string-to-number (ff/file-first-line (format "%s/%s" f prefix))))
+ list-files)))
+
+(defun ff/battery-percent ()