From aa9acfacf0aa04f7339b4fbdaf1138b65192903c Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Sun, 25 Jan 2026 11:21:02 +0100 Subject: [PATCH] Check that a UPower battery device IsPresent The composite DisplayDevice is meant to be presented to the user only if it IsPresent. It is not entirely clear whether PowerSupply implies IsPresent, so check both (bug#80229). * lisp/battery.el (battery-upower): Skip hot-removable batteries that are missing from the bay. --- lisp/battery.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/battery.el b/lisp/battery.el index aa0c0b81b62..ee3e24b196c 100644 --- a/lisp/battery.el +++ b/lisp/battery.el @@ -914,8 +914,10 @@ The following %-sequences are provided: ((and (eq type 1) (not (eq line-status 'online))) ;; It's a line power device: `online' if currently providing ;; power, any other non-nil value if simply present. - (setq line-status (if (cdr (assoc "Online" props)) 'online t))) - ((and (eq type 2) (cdr (assoc "IsPresent" props))) + (setq line-status (or (not (cdr (assoc "Online" props))) 'online))) + ((and (eq type 2) + (cdr (assoc "PowerSupply" props)) + (cdr (assoc "IsPresent" props))) ;; It's a battery. (setq count (1+ count)) (setq state (battery--upower-state props state))