Package: acpi
Version: 1.7-1.1
Severity: wishlist
Tags: upstream patch
X-Debbugs-Cc: t...@mirbsd.de

$ acpi
Battery 0: Discharging, 58%, 01:48:28 remaining

When I run this command multiple times, I cannot see
whether the rate goes up or down, at least not easily
(need to output the time-of-running and calculate it
myself).

With the patch below, this becomes:

$ acpi
Battery 0: Discharging, 57%, 00:53:53 remaining (ca. 2020-11-25T03:22:39+0100)
$ acpi
Battery 0: Discharging, 57%, 01:42:19 remaining (ca. 2020-11-25T04:11:16+0100)

Two mostly-consecutive calls, but the first one still
had the man-db update running on another terminal, so
I can now see easily the discharging rate goes down.

Oh, and please also drop the useless AM_CFLAGS line
from debian/rules, it's not only unused but also wrong ;-)

Thanks in advance for applying and forwarding upstream!


diff -u acpi-1.7/debian/changelog acpi-1.7/debian/changelog
--- acpi-1.7/debian/changelog
+++ acpi-1.7/debian/changelog
@@ -1,3 +1,10 @@
+acpi (1.7-1.2) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Display estimated end time for {,dis}charging, too
+
+ -- Thorsten Glaser <t...@mirbsd.de>  Wed, 25 Nov 2020 02:24:31 +0100
+
 acpi (1.7-1.1) unstable; urgency=medium
 
   * Non-maintainer upload.
only in patch2:
unchanged:
--- acpi-1.7.orig/acpi.c
+++ acpi-1.7/acpi.c
@@ -26,6 +26,7 @@
 #include <getopt.h>
 #include <string.h>
 #include <errno.h>
+#include <time.h>
 
 #include "list.h"
 #include "acpi.h"
@@ -383,11 +384,19 @@
                }
 
                if (seconds > 0) {
+                   char stm[128];
+                   time_t t = time(NULL) + seconds;
+                   struct tm tm;
+
+                   if (!localtime_r(&t, &tm) || !strftime(stm, sizeof(stm),
+                     " (ca. %FT%T%z)", &tm))
+                       stm[0] = '\0';
+
                    hours = seconds / 3600;
                    seconds -= 3600 * hours;
                    minutes = seconds / 60;
                    seconds -= 60 * minutes;
-                   printf(", %02d:%02d:%02d%s", hours, minutes, seconds, 
poststr);
+                   printf(", %02d:%02d:%02d%s%s", hours, minutes, seconds, 
poststr, stm);
                } else if (poststr != NULL) {
                    printf(", %s", poststr);
                }


-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable-debug
  APT policy: (500, 'unstable-debug'), (500, 'oldstable-updates'), (500, 
'buildd-unstable'), (500, 'unstable'), (500, 'oldstable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.9.0-3-amd64 (SMP w/2 CPU threads)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/lksh
Init: sysvinit (via /sbin/init)

Versions of packages acpi depends on:
ii  libc6  2.31-4

acpi recommends no packages.

acpi suggests no packages.

-- no debconf information

Reply via email to