- (cond ((string= field "charging state")
- (cond ((string= value "charged") (setq state 'charged))
- ((string= value "charging") (setq state 'charging))
- ((string= value "discharging")(setq state 'discharging))
- (t (setq state 'unknown))))
-
- ((string= field "remaining capacity")
- (setq charge (string-to-number value)))
-
- ((string= field "present rate")
- (setq rate (string-to-number value)))))))
-
- (with-temp-buffer
- (insert-file-contents-literally (concat path "/info"))
- (while (re-search-forward "^\\([a-z ]*\\): *\\(.*\\)$" nil t)
- (let ((field (match-string 1))
- (value (match-string 2)))
-
- (cond ((string= field "last full capacity")
- (setq full (string-to-number value)))))))
-
- (list state full charge rate)))
-
-(defun ff/thermal-info (path)
- (let ((temperature nil))
- (with-temp-buffer
- (insert-file-contents-literally (concat path "/temperature"))
- (while (re-search-forward "^\\([a-z ]*\\): *\\(.*\\)$" nil t)
- (let ((field (match-string 1))
- (value (match-string 2)))
-
- (cond ((string= field "temperature")
- (setq temperature (string-to-number value)))))))
-
- (list temperature)))
+(defun ff/battery-percent (prefix)
+ (condition-case nil
+ (/ (* 100 (string-to-number (ff/file-first-line (format "%s/%s_now" ff/battery-dir prefix))))
+ (string-to-number (ff/file-first-line (format "%s/%s_full" ff/battery-dir prefix))))
+ (error -1))
+ )