From unknown Sun Jun 22 00:17:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41542: Implement %b status to battery-linux-sysfs in emacs 26.3 (with better percentage-now treatment) Resent-From: Ellington Santos Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 May 2020 14:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41542 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 41542@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15905029676759 (code B ref -1); Tue, 26 May 2020 14:23:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 May 2020 14:22:47 +0000 Received: from localhost ([127.0.0.1]:46055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdaTf-0001kx-Dz for submit@debbugs.gnu.org; Tue, 26 May 2020 10:22:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:50980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdaTd-0001ko-JU for submit@debbugs.gnu.org; Tue, 26 May 2020 10:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdaTd-0001Qn-E6 for bug-gnu-emacs@gnu.org; Tue, 26 May 2020 10:22:45 -0400 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]:36908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdaTc-0000Ac-Id for bug-gnu-emacs@gnu.org; Tue, 26 May 2020 10:22:45 -0400 Received: by mail-qt1-x82e.google.com with SMTP id x29so3010794qtv.4 for ; Tue, 26 May 2020 07:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:date:mime-version; bh=4PxTvOeN7J4oLupX747UJHPsR5n7QKWBU2gaS9bi1UI=; b=igNJ0bDjfzzv9lYbPyJmZL1ikgtHI2WcUpbMO4L9cmMug73z6onb5+8aWk2j8SAmh0 Sc9Gk65XPx7Pftp46CAty7+cdUNmkhZfc9MIihht0UHdZgkTmg/7WC3pcOrYgaOJLcA7 jbqrwlh/TK9IsyI+cnvefoK0czd3CO3+9RAritEVBvJE8frPTs61Ke1nCMrQE/rS751/ ct0iK63XItUIQVD//oNdCh0oyDKLHt3fDh0XjTlm757A7wSb/SR7sVPCedgea59xyZV+ 2DYmegeQb76IIa/i3Yqq13dGlIvwFa1Qn+Jt7WGicStFfRBaAbSWtF6jy9KA3tNjggLg ZYvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version; bh=4PxTvOeN7J4oLupX747UJHPsR5n7QKWBU2gaS9bi1UI=; b=pyO2pNQlADYi3AeE7bEUCRMHS5+LPZId1gTP/6zOed4II/U2V8gtoghr5FmC+CJF/Z qD6x+QvcuH7Irzfd2UBg1vFuAd9v7QrVRaSdCFoUNUepCXxTGzriFdTu3ym7SS3SvfYt SUUdt0H853pnbiRC+4EJWeCXpHXJ8mtMG8gXHllo1QkXse4wmLoCvEJOGzdqmjodCySH uM34ZsHMAH6xlVEQs7l+rfcU6KxyWFpMQ90Ax7wo60TDWrYHCHJS77Kpq1nmq9zXRGoa /hv4rC9gcCR+WjMIU9CHuKgpAaI2hlGbpZJRPtNX3eSZ4diM6C9oHG8wx2PXpbofgvX5 mf2A== X-Gm-Message-State: AOAM531Jalq5hAjC5KV1ZALKXRa+TM+kxi7wi+JzrFCugiKGUGlpB7o3 HFL6+yW3jbcSU5coitYKkw97EY+S X-Google-Smtp-Source: ABdhPJxyCKcCrc4r0IUPtbcZMFeWNEmulioj5kXtiskl/ftmhi7a3GrmLOsVao0/pZZVVxtY9iNjmA== X-Received: by 2002:ac8:2df9:: with SMTP id q54mr1438117qta.215.1590502962487; Tue, 26 May 2020 07:22:42 -0700 (PDT) Received: from x250.gmail.com ([201.17.106.129]) by smtp.gmail.com with ESMTPSA id m6sm16785884qkc.4.2020.05.26.07.22.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:22:41 -0700 (PDT) User-agent: mu4e 1.4.7; emacs 26.3 From: Ellington Santos Message-ID: <87eer64vyo.fsf@gmail.com> Date: Tue, 26 May 2020 11:22:39 -0300 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=ellingtonsantos@gmail.com; helo=mail-qt1-x82e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain; format=flowed This patch implements %b battery status to battery-linux-sysfs in emacs-26.3 battery.el --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=battery_sysfs_b_status.patch 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" --=-=-= Content-Type: text/plain; format=flowed -- Atenciosamente, Ellington Santos --=-=-=-- From unknown Sun Jun 22 00:17:51 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41542: Diff patch wrong in my last post. Follow right one References: <87eer64vyo.fsf@gmail.com> In-Reply-To: <87eer64vyo.fsf@gmail.com> Resent-From: Ellington Santos Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 26 May 2020 14:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41542 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 41542@debbugs.gnu.org Received: via spool by 41542-submit@debbugs.gnu.org id=B41542.15905038368144 (code B ref 41542); Tue, 26 May 2020 14:38:02 +0000 Received: (at 41542) by debbugs.gnu.org; 26 May 2020 14:37:16 +0000 Received: from localhost ([127.0.0.1]:46065 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdahf-00027I-NA for submit@debbugs.gnu.org; Tue, 26 May 2020 10:37:15 -0400 Received: from mail-qk1-f182.google.com ([209.85.222.182]:34834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdahd-000274-Sv for 41542@debbugs.gnu.org; Tue, 26 May 2020 10:37:14 -0400 Received: by mail-qk1-f182.google.com with SMTP id n141so8331864qke.2 for <41542@debbugs.gnu.org>; Tue, 26 May 2020 07:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:date:mime-version; bh=l1IV2xMtfqfuq9OGsJtIT3NBN8F6p8qf5l0g8B6ksGE=; b=iEExgcN4Vx0m0uiQL5lNaDtHYEXSK/yVMDIb3gG2HBRPJ65Rq1H2ZMmgdPU5O/LfXC BjshYKN0wCc7yEga//T1i9qYjJVSQ6JuyVmQWhboATUkUyCO+JS31j2JpSFj+Oo7ixza sUlB/yCnu6vzQRI+f0uvJHoiX9IImBO9omKV0JjZc9aBDmXg4131+dncdjmCBP47JRRQ vanWLqFsKjRNIZSq0fiFE4IkqwELo4uLMJI0mgLXZR1itG3suGyOev0QYe8bL6pQfvoi OzmzSwwBCHZgfmnmq38PyMaYTRJs+S3OHEUr6Ytg3FoTt2KfFPLP/5Sdhf4TmKkMtKJt g2Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version; bh=l1IV2xMtfqfuq9OGsJtIT3NBN8F6p8qf5l0g8B6ksGE=; b=nuIvG+Kg1OpxX39T3u9Qpx78Z7mP+oZDKZOKsXYHkjRd1cG/En6ShPqw5T10c0Hczf Db102n2FF88tes4d45UbK2p2My98MVA6rtnZtNqsD0fBqgT9oFUJbSsHAun1HX05W7Q/ 5rOKIkIVXMsbLcu4Om00/pBmR85/nJWyXJF34BTn9MX4e9pHlPqfSZEoUMF/k0Shee+s 1VNXmaJoO8qDKh07kVZ3X8f87uGf99Mk6Mr5hwReuwi5+a9HBQZHTkx7WHTKmMvvCbMK 4Er0zgBQIPREvjKc/8Eihdino8k3/+F9tE+5qhS12JRwRNx8E7ETlsewkCm3j76RubgZ CP6g== X-Gm-Message-State: AOAM530RQfM6xdZIy03/5RFEJAadbbOPLeTgPMmLEUnSb3GjqviROtuH QJDSEUcniKO7XPQRKCzKd4qXrqcd X-Google-Smtp-Source: ABdhPJz6CDdASddSe0+J4kLcGLQ5TAkR01upVBTWtBROekwt04V5uUXbdeBfdQHrzGOOVTFTUclkOQ== X-Received: by 2002:a37:59c7:: with SMTP id n190mr1681587qkb.471.1590503827049; Tue, 26 May 2020 07:37:07 -0700 (PDT) Received: from x250.gmail.com ([201.17.106.129]) by smtp.gmail.com with ESMTPSA id k17sm6707713qtb.5.2020.05.26.07.37.05 for <41542@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:37:06 -0700 (PDT) User-agent: mu4e 1.4.7; emacs 26.3 From: Ellington Santos Message-ID: <87blma4van.fsf@gmail.com> Date: Tue, 26 May 2020 11:37:04 -0300 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=battery_sysfs_b_status.patch diff --git a/lisp/battery.el b/lisp/battery.el index e23dab4c91..309f43f8cd 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 @@ -509,6 +511,8 @@ The following %-sequences are provided: energy-now (- energy-full energy-now)))) (setq hours (/ remaining power-now))))))) + (when (and (> energy-full 0) (> energy-now 0)) + (setq percentage-now (/ (* 100 energy-now) energy-full))) (list (cons ?c (cond ((or (> energy-full 0) (> energy-now 0)) (number-to-string (/ energy-now voltage-now))) (t "N/A"))) @@ -522,10 +526,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" --=-=-= Content-Type: text/plain; format=flowed -- Atenciosamente, Ellington Santos --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed May 27 17:29:01 2020 Received: (at control) by debbugs.gnu.org; 27 May 2020 21:29:01 +0000 Received: from localhost ([127.0.0.1]:50151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1je3bh-0005vt-3E for submit@debbugs.gnu.org; Wed, 27 May 2020 17:29:01 -0400 Received: from mail-il1-f175.google.com ([209.85.166.175]:39954) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1je3bf-0005ve-F9; Wed, 27 May 2020 17:28:59 -0400 Received: by mail-il1-f175.google.com with SMTP id a18so8327331ilp.7; Wed, 27 May 2020 14:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=2x1Uk7kCOYw+EDfI8IXb6a8xpF3UAI/UkhFpkIq5MeQ=; b=Th3CsMNn0WeWoYa2zJRWB3hxRiHAHlyDARZNLLtzBqNwdx6BrTJxXcwojNtGv/Ualt hDDRLdia+9pYpttbB+k7wjO/mJDhdNsOfU3uEhmOQceSsVoOwFKk4X/92qfZJr6jToeI 8AfLwxFu+ML7J6ckz69fioOjBfFsT0fobrUZbr9YF4qPA2oJrZnHSNKza2+pEkf2tbxt DZfyflnQwIlZEIKQU+DqxwgKYvB3tIqPy3v5o0WyZ06LWwcl0D8HQ+fA+FE2m+DNqFUm 5uceBGT/QZ+WkTeNTywRBCAunEh6nmWOsxDO017cvhkkASinAzf14S3cknYGZSyF5hez Uxaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=2x1Uk7kCOYw+EDfI8IXb6a8xpF3UAI/UkhFpkIq5MeQ=; b=TWH0c/A1wiMF5PIAQdKeYJ4ZjTG4gSjMnTXt+tpoASmzKs8owl6+vJBLkJCvqyMGpA /8eDaV02exkL0pEb/Mda0+aPEFoj4gRAQ3IVmexQCo812Rg/sU92BtkulvkGal+63pe1 pbtFkcTnl4VWlswnrki9U0+9UrTn0Ce/sgwmRzFL63WCjoaPduf/Iy+g6iPTU9x29z66 SooSW/jALtcFrTd0km1Zn1CpGPiL7qmomIRZT98AGkL8nrFzyZEucM83LMQWleoTXg5Z ZkSWU+3RmX8ymDmY9yqoJyJVc+YI/RQhVC/SjoQRg/yNcvImuJZ/Y05whKBNnaxmGh5S tR0Q== X-Gm-Message-State: AOAM532e5SIDv4nT1HExgolDaZ/yyGCZTkTLK2JJXL4hXyvzpjxH6TkH X6JugjgJ+4beMekUzKxNlGqmWRB4 X-Google-Smtp-Source: ABdhPJzGnVQQq1opn0l5yzhdilBtXwS4ErtzBq3QIcLFGj1bfXEDxxKODdp/+nDHfeQaIEQK9oLkVg== X-Received: by 2002:a05:6e02:46:: with SMTP id i6mr254295ilr.298.1590614933812; Wed, 27 May 2020 14:28:53 -0700 (PDT) Received: from vhost2 (CPE001143542e1f-CMf81d0f809fa0.cpe.net.cable.rogers.com. [99.230.38.42]) by smtp.gmail.com with ESMTPSA id m12sm397188ili.41.2020.05.27.14.28.53 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 May 2020 14:28:53 -0700 (PDT) From: Noam Postavsky To: Ellington Santos Subject: Re: bug#41540: Implement %b status to battery-linux-sysfs in emacs 26.3 References: <87h7w24wy9.fsf@gmail.com> Date: Wed, 27 May 2020 17:28:52 -0400 In-Reply-To: <87h7w24wy9.fsf@gmail.com> (Ellington Santos's message of "Tue, 26 May 2020 11:01:18 -0300") Message-ID: <85a71tt6cr.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control Cc: 41540@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) forwarded 41540 https://debbugs.gnu.org/41542 close 41540 severity 41542 wishlist tags 41542 + patch quit This bug seems to have been accidentally duped. Closing in favour of the newer thread. From unknown Sun Jun 22 00:17:51 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Ellington Santos Subject: bug#41542: closed (Re: bug#41542: Diff patch wrong in my last post. Follow right one) Message-ID: References: <834kroaamu.fsf@gnu.org> <87eer64vyo.fsf@gmail.com> X-Gnu-PR-Message: they-closed 41542 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 41542@debbugs.gnu.org Date: Sat, 06 Jun 2020 07:59:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1591430343-22042-1" This is a multi-part message in MIME format... ------------=_1591430343-22042-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #41542: Implement %b status to battery-linux-sysfs in emacs 26.3 (with bett= er percentage-now treatment) which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 41542@debbugs.gnu.org. --=20 41542: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D41542 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1591430343-22042-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 41542-done) by debbugs.gnu.org; 6 Jun 2020 07:58:54 +0000 Received: from localhost ([127.0.0.1]:50611 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhTjC-0005il-DY for submit@debbugs.gnu.org; Sat, 06 Jun 2020 03:58:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57732) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhTj7-0005iU-PY for 41542-done@debbugs.gnu.org; Sat, 06 Jun 2020 03:58:50 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57564) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhTj2-0005xb-FZ; Sat, 06 Jun 2020 03:58:44 -0400 Received: from [176.228.60.248] (port=1641 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jhTj0-0003HB-Bz; Sat, 06 Jun 2020 03:58:42 -0400 Date: Sat, 06 Jun 2020 10:58:33 +0300 Message-Id: <834kroaamu.fsf@gnu.org> From: Eli Zaretskii To: Ellington Santos In-Reply-To: <87blma4van.fsf@gmail.com> (message from Ellington Santos on Tue, 26 May 2020 11:37:04 -0300) Subject: Re: bug#41542: Diff patch wrong in my last post. Follow right one References: <87eer64vyo.fsf@gmail.com> <87blma4van.fsf@gmail.com> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 41542-done Cc: 41542-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ellington Santos > 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. ------------=_1591430343-22042-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 26 May 2020 14:22:47 +0000 Received: from localhost ([127.0.0.1]:46055 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdaTf-0001kx-Dz for submit@debbugs.gnu.org; Tue, 26 May 2020 10:22:47 -0400 Received: from lists.gnu.org ([209.51.188.17]:50980) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jdaTd-0001ko-JU for submit@debbugs.gnu.org; Tue, 26 May 2020 10:22:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jdaTd-0001Qn-E6 for bug-gnu-emacs@gnu.org; Tue, 26 May 2020 10:22:45 -0400 Received: from mail-qt1-x82e.google.com ([2607:f8b0:4864:20::82e]:36908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jdaTc-0000Ac-Id for bug-gnu-emacs@gnu.org; Tue, 26 May 2020 10:22:45 -0400 Received: by mail-qt1-x82e.google.com with SMTP id x29so3010794qtv.4 for ; Tue, 26 May 2020 07:22:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:message-id:date:mime-version; bh=4PxTvOeN7J4oLupX747UJHPsR5n7QKWBU2gaS9bi1UI=; b=igNJ0bDjfzzv9lYbPyJmZL1ikgtHI2WcUpbMO4L9cmMug73z6onb5+8aWk2j8SAmh0 Sc9Gk65XPx7Pftp46CAty7+cdUNmkhZfc9MIihht0UHdZgkTmg/7WC3pcOrYgaOJLcA7 jbqrwlh/TK9IsyI+cnvefoK0czd3CO3+9RAritEVBvJE8frPTs61Ke1nCMrQE/rS751/ ct0iK63XItUIQVD//oNdCh0oyDKLHt3fDh0XjTlm757A7wSb/SR7sVPCedgea59xyZV+ 2DYmegeQb76IIa/i3Yqq13dGlIvwFa1Qn+Jt7WGicStFfRBaAbSWtF6jy9KA3tNjggLg ZYvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:message-id:date :mime-version; bh=4PxTvOeN7J4oLupX747UJHPsR5n7QKWBU2gaS9bi1UI=; b=pyO2pNQlADYi3AeE7bEUCRMHS5+LPZId1gTP/6zOed4II/U2V8gtoghr5FmC+CJF/Z qD6x+QvcuH7Irzfd2UBg1vFuAd9v7QrVRaSdCFoUNUepCXxTGzriFdTu3ym7SS3SvfYt SUUdt0H853pnbiRC+4EJWeCXpHXJ8mtMG8gXHllo1QkXse4wmLoCvEJOGzdqmjodCySH uM34ZsHMAH6xlVEQs7l+rfcU6KxyWFpMQ90Ax7wo60TDWrYHCHJS77Kpq1nmq9zXRGoa /hv4rC9gcCR+WjMIU9CHuKgpAaI2hlGbpZJRPtNX3eSZ4diM6C9oHG8wx2PXpbofgvX5 mf2A== X-Gm-Message-State: AOAM531Jalq5hAjC5KV1ZALKXRa+TM+kxi7wi+JzrFCugiKGUGlpB7o3 HFL6+yW3jbcSU5coitYKkw97EY+S X-Google-Smtp-Source: ABdhPJxyCKcCrc4r0IUPtbcZMFeWNEmulioj5kXtiskl/ftmhi7a3GrmLOsVao0/pZZVVxtY9iNjmA== X-Received: by 2002:ac8:2df9:: with SMTP id q54mr1438117qta.215.1590502962487; Tue, 26 May 2020 07:22:42 -0700 (PDT) Received: from x250.gmail.com ([201.17.106.129]) by smtp.gmail.com with ESMTPSA id m6sm16785884qkc.4.2020.05.26.07.22.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 07:22:41 -0700 (PDT) User-agent: mu4e 1.4.7; emacs 26.3 From: Ellington Santos To: bug-gnu-emacs@gnu.org Subject: Implement %b status to battery-linux-sysfs in emacs 26.3 (with better percentage-now treatment) Message-ID: <87eer64vyo.fsf@gmail.com> Date: Tue, 26 May 2020 11:22:39 -0300 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::82e; envelope-from=ellingtonsantos@gmail.com; helo=mail-qt1-x82e.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain; format=flowed This patch implements %b battery status to battery-linux-sysfs in emacs-26.3 battery.el --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=battery_sysfs_b_status.patch 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" --=-=-= Content-Type: text/plain; format=flowed -- Atenciosamente, Ellington Santos --=-=-=-- ------------=_1591430343-22042-1--