Fix error when directory `/sys` is not readable by the user

This commit is contained in:
Lucien Cartier-Tilet 2021-12-18 17:26:48 +01:00
parent 6e90f02988
commit 76d87e4325
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 4 additions and 3 deletions

View File

@ -2,7 +2,7 @@
;; Author: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Maintainer: Lucien Cartier-Tilet <lucien@phundrak.com>
;; Version: 0.7.5
;; Version: 0.7.6
;; Package-Requires: ((emacs "25.1") (f "0.20") (s "1"))
;; Homepage: https://github.com/Phundrak/eshell-info-banner.el
@ -552,8 +552,9 @@ The usage of `eshell-info-banner-warning-percentage' and
thought of as the percentage of discharge of the computer.
Thus, setting the warning at 75% will be translated as showing
the warning face with a battery level of 25% or less."
(let ((battery-level (battery)))
(if (or (string= battery-level "Battery status not available")
(let ((battery-level (when (file-readable-p "/sys/") (battery))))
(if (or (null battery-level)
(string= battery-level "Battery status not available")
(string-match-p (regexp-quote "N/A") battery-level))
""
(let ((percentage (save-match-data