From e0a4eaa69171378664e28e8ab30a0e83e09ce19c Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Wed, 5 Oct 2022 15:59:14 +0200 Subject: [PATCH] Fix BSD battery mode over TRAMP * lisp/battery.el (call-process-to-string): Simple wrapper to `call-process' that outputs to a string. (battery-bsd-apm): Use it instead of `shell-command-to-string'. --- lisp/battery.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lisp/battery.el b/lisp/battery.el index 72b3dfdae7..0fae92ab98 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -913,6 +913,10 @@ battery-upower ;;; `apm' interface for BSD. +(defun call-process-to-string (program &rest args) + (with-output-to-string + (with-current-buffer standard-output + (apply #'call-process program nil t nil args)))) (defun battery-bsd-apm () "Get APM status information from BSD apm binary. @@ -929,13 +933,13 @@ battery-bsd-apm %t Remaining time (to charge or discharge) in the form `h:min'" (let* ((os-name (car (split-string ;; FIXME: Can't we use something like `system-type'? - (shell-command-to-string "/usr/bin/uname")))) + (call-process-to-string "/usr/bin/uname")))) (apm-flag (pcase os-name ("OpenBSD" "mP") ("FreeBSD" "st") (_ "ms"))) - (apm-cmd (concat "/usr/sbin/apm -abl" apm-flag)) - (apm-output (split-string (shell-command-to-string apm-cmd))) + (apm-args (concat "-abl" apm-flag)) + (apm-output (split-string (call-process-to-string "/usr/sbin/apm" apm-args))) (indices (pcase os-name ;; FreeBSD's manpage documents that multiple ;; outputs are ordered by "the order in which -- 2.37.3