From a6ea372e02c5f8e583ea216743cf238854a8fc90 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Wed, 5 Jan 2022 15:59:33 +0100 Subject: [PATCH] ; * lisp/battery.el (battery-status-function) Fix errors in Termux In Termux, neither /sys/ or /proc/ are readable on phones that are not rooted. This patch makes Emacs verify if they are readable before it attemps reading them. --- lisp/battery.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/battery.el b/lisp/battery.el index 45334163fa..b7b81a11a1 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -96,12 +96,14 @@ Value does not include \".\" or \"..\"." (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) ((and (eq system-type 'berkeley-unix) -- 2.34.1