pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/sysutils/xbattbar Look for the indicator "charging" to...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/d1238e7663de
branches:  trunk
changeset: 531213:d1238e7663de
user:      xtraeme <xtraeme%pkgsrc.org@localhost>
date:      Wed Jul 25 15:09:32 2007 +0000

description:
Look for the indicator "charging" to know when the AC Adapter is plugged
in/off, so that it works fine with -current where the 'discharging'
sensor was removed.

Found by pooka@... bump PKGREVISION.

diffstat:

 sysutils/xbattbar/Makefile         |   4 +-
 sysutils/xbattbar/distinfo         |   4 +-
 sysutils/xbattbar/patches/patch-ab |  88 ++++++++++++++-----------------------
 3 files changed, 38 insertions(+), 58 deletions(-)

diffs (181 lines):

diff -r 402dd9d45369 -r d1238e7663de sysutils/xbattbar/Makefile
--- a/sysutils/xbattbar/Makefile        Wed Jul 25 15:01:45 2007 +0000
+++ b/sysutils/xbattbar/Makefile        Wed Jul 25 15:09:32 2007 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.29 2007/01/22 23:42:38 abs Exp $
+# $NetBSD: Makefile,v 1.30 2007/07/25 15:09:32 xtraeme Exp $
 
 DISTNAME=      xbattbar_1.4.2
 PKGNAME=       ${DISTNAME:S/_/-/}
-PKGREVISION=   6
+PKGREVISION=   7
 CATEGORIES=    sysutils x11
 MASTER_SITES=  http://iplab.aist-nara.ac.jp/member/suguru/
 
diff -r 402dd9d45369 -r d1238e7663de sysutils/xbattbar/distinfo
--- a/sysutils/xbattbar/distinfo        Wed Jul 25 15:01:45 2007 +0000
+++ b/sysutils/xbattbar/distinfo        Wed Jul 25 15:09:32 2007 +0000
@@ -1,8 +1,8 @@
-$NetBSD: distinfo,v 1.11 2005/02/24 13:40:59 agc Exp $
+$NetBSD: distinfo,v 1.12 2007/07/25 15:09:32 xtraeme Exp $
 
 SHA1 (xbattbar_1.4.2.tar.gz) = 14e9aafd62919e4a625d3f84df3b074b9eef8279
 RMD160 (xbattbar_1.4.2.tar.gz) = f28a273a1865a0919e32144bbb5b16b3c0340061
 Size (xbattbar_1.4.2.tar.gz) = 14079 bytes
 SHA1 (patch-aa) = 3bd4b688ccaeebe766335245c1a8c5dde52768c2
-SHA1 (patch-ab) = dfaf520dcc10228da4ab4c222210f0ecb4914f4f
+SHA1 (patch-ab) = b3115d01555e62c0229350213b003d9f2d554968
 SHA1 (patch-ac) = 507cdf9b4e79dc577d020963142e262d04536527
diff -r 402dd9d45369 -r d1238e7663de sysutils/xbattbar/patches/patch-ab
--- a/sysutils/xbattbar/patches/patch-ab        Wed Jul 25 15:01:45 2007 +0000
+++ b/sysutils/xbattbar/patches/patch-ab        Wed Jul 25 15:09:32 2007 +0000
@@ -1,7 +1,7 @@
-$NetBSD: patch-ab,v 1.6 2003/11/10 23:53:32 mrg Exp $
+$NetBSD: patch-ab,v 1.7 2007/07/25 15:09:32 xtraeme Exp $
 
---- xbattbar.c.orig    2001-02-02 16:25:29.000000000 +1100
-+++ xbattbar.c 2003-11-10 17:50:08.000000000 +1100
+--- xbattbar.c.orig    2001-02-02 06:25:29.000000000 +0100
++++ xbattbar.c 2007-07-25 17:03:43.000000000 +0200
 @@ -27,6 +27,14 @@
  
  #include <sys/types.h>
@@ -17,7 +17,7 @@
  #include <signal.h>
  #include <stdio.h>
  #include <unistd.h>
-@@ -583,39 +591,174 @@
+@@ -583,27 +591,161 @@
  #define _PATH_APM_CTLDEV       "/dev/apmctl"
  #define _PATH_APM_NORMAL       "/dev/apm"
  
@@ -89,10 +89,6 @@
  {
         int fd, r, p;
         struct apm_power_info info;
--
--       if ((fd = open(_PATH_APM_NORMAL, O_RDONLY)) == -1) {
--               fprintf(stderr, "xbattbar: cannot open apm device\n");
--               exit(1);
 +       int acpi;
 +       size_t ns;
 +       size_t cc;
@@ -107,22 +103,20 @@
 +             fd = open(apmdev, O_RDONLY);
 +             acpi = 1;
 +#endif
-        }
--
--       if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) {
--               fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n");
++       }
 +       if (fd < 0) {
 +               fprintf(stderr, "xbattbar: cannot open %s device\n", apmdev);
-                exit(1);
-        }
++               exit(1);
++       }
  
--       close(fd);
+-       if ((fd = open(_PATH_APM_NORMAL, O_RDONLY)) == -1) {
+-               fprintf(stderr, "xbattbar: cannot open apm device\n");
 +       if (acpi) {
 +#ifdef HAVE_NETBSD_ACPI
 +              if ((ns = numsensors(fd)) == 0) {
 +                     fprintf(stderr, "xbattbar: no sensors found\n");
-+                     exit(1);
-+              }
+                exit(1);
+        }
 +              if (first) {
 +                      cetds = (int *)malloc(ns * sizeof(int));
 +                      etds = (envsys_tre_data_t *)malloc(ns * sizeof(envsys_tre_data_t));
@@ -132,36 +126,28 @@
 +                              err(1, "Out of memory");
 +                      }
 +              }
- 
--       ++elapsed_time;
++
 +              fillsensors(fd, etds, ebis, ns);
  
--       /* get current remoain */
--       if (info.battery_life > 100) {
--               /* some APM BIOSes return values slightly > 100 */
--               r = 100;
 +#endif
-        } else {
--               r = info.battery_life;
++       } else {
 +
 +             memset(&info, 0, sizeof(info));
-+             if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) {
-+                     fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n");
-+                     exit(1);
-+             }
+        if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) {
+                fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n");
+                exit(1);
         }
++       }
  
--       /* get AC-line status */
--       if (info.ac_state == APM_AC_ON) {
--               p = APM_AC_ON;
-+       close(fd);
-+
-+       ++elapsed_time;
-+
+        close(fd);
+ 
+        ++elapsed_time;
+ 
+-       /* get current remoain */
 +       if (acpi) {
 +#ifdef HAVE_NETBSD_ACPI
 +              int32_t rtot = 0, maxtot = 0;
-+              p = APM_AC_ON;
++              p = APM_AC_OFF;
 +              for (i = 0 ; i < ns ; i++) {
 +                      if ((etds[i].validflags & ENVSYS_FCURVALID) == 0)
 +                              continue;
@@ -185,28 +171,22 @@
 +                      if (ebis[i].units == ENVSYS_INDICATOR &&
 +                          etds[i].cur.data_s &&
 +                          strncmp(ebis[i].desc, "acpibat", 7) == 0 &&
-+                          strcmp(&ebis[i].desc[cc - 11], "discharging") == 0) {
-+                              p = APM_AC_OFF;
++                          strcmp(&ebis[i].desc[cc - 8], "charging") == 0) {
++                              p = APM_AC_ON;
 +                      }
 +              }
 +              r = (rtot * 100.0) / maxtot;
 +#endif
-        } else {
--               p = APM_AC_OFF;
++       } else {
 +             /* get current remain */
-+             if (info.battery_life > 100) {
-+                     /* some APM BIOSes return values slightly > 100 */
-+                     r = 100;
-+             } else {
-+                     r = info.battery_life;
-+             }
-+
-+             /* get AC-line status */
-+             if (info.ac_state == APM_AC_ON) {
-+                     p = APM_AC_ON;
-+             } else {
-+                     p = APM_AC_OFF;
-+             }
+        if (info.battery_life > 100) {
+                /* some APM BIOSes return values slightly > 100 */
+                r = 100;
+@@ -617,6 +759,7 @@
+        } else {
+                p = APM_AC_OFF;
         }
++       }
  
         if (first || ac_line != p || battery_level != r) {
+                first = 0;



Home | Main Index | Thread Index | Old Index