bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#18157: 24.4.50; battery-pmset fails to report critical battery state


From: Marcin Borkowski
Subject: bug#18157: 24.4.50; battery-pmset fails to report critical battery state
Date: Tue, 16 Feb 2016 15:56:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

On 2014-07-31, at 16:16, Sebastian Wiesner <address@hidden> wrote:

> `battery-pmset' fails to correctly report critical battery state:  Even
> if the battery charge level is below `battery-load-critical', it reports
> "low" battery state only.
>
> The culprit is the `cond' expression in the body of `battery-pmset'
> which compares the reported `load-percentage' against `battery-load-low'
> first, and then against `battery-load-critical'.
>
> Since the latter is typically lower, it will never be reached, because
> `cond' already returns after the former succeeded.
>
> To fix this issue, `batter-pmset' needs to check `battery-load-critical'
> *first*, and then `battery-load-low'.

Does this patch help?

--8<---------------cut here---------------start------------->8---
diff -u --label /usr/local/share/emacs/25.1.50/lisp/battery.el.gz --label 
\#\<buffer\ battery.el.gz\> /tmp/jka-com1889YvM /tmp/buffer-content-1889yDZ
--- /usr/local/share/emacs/25.1.50/lisp/battery.el.gz
+++ #<buffer battery.el.gz>
@@ -628,12 +628,12 @@
            (cond ((looking-at "; charging")
                   (setq battery-status "charging"
                         battery-status-symbol "+"))
-                 ((< (string-to-number load-percentage) battery-load-low)
-                  (setq battery-status "low"
-                        battery-status-symbol "-"))
                  ((< (string-to-number load-percentage) battery-load-critical)
                   (setq battery-status "critical"
                         battery-status-symbol "!"))
+                 ((< (string-to-number load-percentage) battery-load-low)
+                  (setq battery-status "low"
+                        battery-status-symbol "-"))
                  (t
                   (setq battery-status "high"
                         battery-status-symbol "")))

Diff finished.  Tue Feb 16 15:56:03 2016
--8<---------------cut here---------------end--------------->8---

Best,

--
mb





reply via email to

[Prev in Thread] Current Thread [Next in Thread]