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

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

bug#41542: closed (Implement %b status to battery-linux-sysfs in emacs 2


From: GNU bug Tracking System
Subject: bug#41542: closed (Implement %b status to battery-linux-sysfs in emacs 26.3 (with better percentage-now treatment))
Date: Sat, 06 Jun 2020 07:59:03 +0000

Your message dated Sat, 06 Jun 2020 10:58:33 +0300
with message-id <834kroaamu.fsf@gnu.org>
and subject line Re: bug#41542: Diff patch wrong in my last post. Follow right 
one
has caused the debbugs.gnu.org bug report #41542,
regarding Implement %b status to battery-linux-sysfs in emacs 26.3 (with better 
percentage-now treatment)
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@gnu.org.)


-- 
41542: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=41542
GNU Bug Tracking System
Contact help-debbugs@gnu.org with problems
--- Begin Message --- Subject: Implement %b status to battery-linux-sysfs in emacs 26.3 (with better percentage-now treatment) Date: Tue, 26 May 2020 11:22:39 -0300 User-agent: mu4e 1.4.7; emacs 26.3 This patch implements %b battery status to battery-linux-sysfs in emacs-26.3 battery.el

diff --git a/lisp/battery.el b/lisp/battery.el
index e23dab4c91..b5c12653e1 100644
--- a/lisp/battery.el
+++ b/lisp/battery.el
@@ -433,13 +433,15 @@ The following %-sequences are provided:
 %c Current capacity (mAh or mWh)
 %r Current rate
 %B Battery status (verbose)
+%b Battery status, empty means high, `-' means low,
+   `!' means critical, and `+' means charging
 %d Temperature (in degrees Celsius)
 %p Battery load percentage
 %L AC line status (verbose)
 %m Remaining time (to charge or discharge) in minutes
 %h Remaining time (to charge or discharge) in hours
 %t Remaining time (to charge or discharge) in the form `h:min'"
-  (let (charging-state temperature hours
+  (let (charging-state temperature hours percentage-now
         ;; Some batteries report charges and current, other energy and power.
         ;; In order to reliably be able to combine those data, we convert them
         ;; all to energy/power (since we can't combine different charges if
@@ -522,10 +524,13 @@ The following %-sequences are provided:
                     "N/A"))
          (cons ?d (or temperature "N/A"))
          (cons ?B (or charging-state "N/A"))
-         (cons ?p (cond ((and (> energy-full 0) (> energy-now 0))
-                         (format "%.1f"
-                                 (/ (* 100 energy-now) energy-full)))
-                        (t "N/A")))
+         (cons ?b (or (and (string= charging-state "Charging") "+")
+                      (and percentage-now (< percentage-now 
battery-load-critical) "!")
+                      (and percentage-now (< percentage-now battery-load-low) 
"-")
+                      ""))
+         (cons ?p (cond
+                    ((and percentage-now (format "%.1f" percentage-now)))
+                    (t "N/A")))
          (cons ?L (cond
                     ((battery-search-for-one-match-in-files
                       (list "/sys/class/power_supply/AC/online"


--

Atenciosamente,

Ellington Santos

--- End Message ---
--- Begin Message --- Subject: Re: bug#41542: Diff patch wrong in my last post. Follow right one Date: Sat, 06 Jun 2020 10:58:33 +0300
> From: Ellington Santos <ellingtonsantos@gmail.com>
> Date: Tue, 26 May 2020 11:37:04 -0300
> 
> diff --git a/lisp/battery.el b/lisp/battery.el
> index e23dab4c91..309f43f8cd 100644
> --- a/lisp/battery.el
> +++ b/lisp/battery.el

Thanks, I installed this on the master branch.

In the future, please also provide a ChangeLog-style commit log
message, as described in CONTRIBUTE.


--- End Message ---

reply via email to

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