head 1.11; access; symbols pkgsrc-2025Q2:1.10.0.58 pkgsrc-2025Q2-base:1.10 pkgsrc-2025Q1:1.10.0.56 pkgsrc-2025Q1-base:1.10 pkgsrc-2024Q4:1.10.0.54 pkgsrc-2024Q4-base:1.10 pkgsrc-2024Q3:1.10.0.52 pkgsrc-2024Q3-base:1.10 pkgsrc-2024Q2:1.10.0.50 pkgsrc-2024Q2-base:1.10 pkgsrc-2024Q1:1.10.0.48 pkgsrc-2024Q1-base:1.10 pkgsrc-2023Q4:1.10.0.46 pkgsrc-2023Q4-base:1.10 pkgsrc-2023Q3:1.10.0.44 pkgsrc-2023Q3-base:1.10 pkgsrc-2023Q2:1.10.0.42 pkgsrc-2023Q2-base:1.10 pkgsrc-2023Q1:1.10.0.40 pkgsrc-2023Q1-base:1.10 pkgsrc-2022Q4:1.10.0.38 pkgsrc-2022Q4-base:1.10 pkgsrc-2022Q3:1.10.0.36 pkgsrc-2022Q3-base:1.10 pkgsrc-2022Q2:1.10.0.34 pkgsrc-2022Q2-base:1.10 pkgsrc-2022Q1:1.10.0.32 pkgsrc-2022Q1-base:1.10 pkgsrc-2021Q4:1.10.0.30 pkgsrc-2021Q4-base:1.10 pkgsrc-2021Q3:1.10.0.28 pkgsrc-2021Q3-base:1.10 pkgsrc-2021Q2:1.10.0.26 pkgsrc-2021Q2-base:1.10 pkgsrc-2021Q1:1.10.0.24 pkgsrc-2021Q1-base:1.10 pkgsrc-2020Q4:1.10.0.22 pkgsrc-2020Q4-base:1.10 pkgsrc-2020Q3:1.10.0.20 pkgsrc-2020Q3-base:1.10 pkgsrc-2020Q2:1.10.0.18 pkgsrc-2020Q2-base:1.10 pkgsrc-2020Q1:1.10.0.14 pkgsrc-2020Q1-base:1.10 pkgsrc-2019Q4:1.10.0.16 pkgsrc-2019Q4-base:1.10 pkgsrc-2019Q3:1.10.0.12 pkgsrc-2019Q3-base:1.10 pkgsrc-2019Q2:1.10.0.10 pkgsrc-2019Q2-base:1.10 pkgsrc-2019Q1:1.10.0.8 pkgsrc-2019Q1-base:1.10 pkgsrc-2018Q4:1.10.0.6 pkgsrc-2018Q4-base:1.10 pkgsrc-2018Q3:1.10.0.4 pkgsrc-2018Q3-base:1.10 pkgsrc-2018Q2:1.10.0.2 pkgsrc-2018Q2-base:1.10 pkgsrc-2018Q1:1.9.0.88 pkgsrc-2018Q1-base:1.9 pkgsrc-2017Q4:1.9.0.86 pkgsrc-2017Q4-base:1.9 pkgsrc-2017Q3:1.9.0.84 pkgsrc-2017Q3-base:1.9 pkgsrc-2017Q2:1.9.0.80 pkgsrc-2017Q2-base:1.9 pkgsrc-2017Q1:1.9.0.78 pkgsrc-2017Q1-base:1.9 pkgsrc-2016Q4:1.9.0.76 pkgsrc-2016Q4-base:1.9 pkgsrc-2016Q3:1.9.0.74 pkgsrc-2016Q3-base:1.9 pkgsrc-2016Q2:1.9.0.72 pkgsrc-2016Q2-base:1.9 pkgsrc-2016Q1:1.9.0.70 pkgsrc-2016Q1-base:1.9 pkgsrc-2015Q4:1.9.0.68 pkgsrc-2015Q4-base:1.9 pkgsrc-2015Q3:1.9.0.66 pkgsrc-2015Q3-base:1.9 pkgsrc-2015Q2:1.9.0.64 pkgsrc-2015Q2-base:1.9 pkgsrc-2015Q1:1.9.0.62 pkgsrc-2015Q1-base:1.9 pkgsrc-2014Q4:1.9.0.60 pkgsrc-2014Q4-base:1.9 pkgsrc-2014Q3:1.9.0.58 pkgsrc-2014Q3-base:1.9 pkgsrc-2014Q2:1.9.0.56 pkgsrc-2014Q2-base:1.9 pkgsrc-2014Q1:1.9.0.54 pkgsrc-2014Q1-base:1.9 pkgsrc-2013Q4:1.9.0.52 pkgsrc-2013Q4-base:1.9 pkgsrc-2013Q3:1.9.0.50 pkgsrc-2013Q3-base:1.9 pkgsrc-2013Q2:1.9.0.48 pkgsrc-2013Q2-base:1.9 pkgsrc-2013Q1:1.9.0.46 pkgsrc-2013Q1-base:1.9 pkgsrc-2012Q4:1.9.0.44 pkgsrc-2012Q4-base:1.9 pkgsrc-2012Q3:1.9.0.42 pkgsrc-2012Q3-base:1.9 pkgsrc-2012Q2:1.9.0.40 pkgsrc-2012Q2-base:1.9 pkgsrc-2012Q1:1.9.0.38 pkgsrc-2012Q1-base:1.9 pkgsrc-2011Q4:1.9.0.36 pkgsrc-2011Q4-base:1.9 pkgsrc-2011Q3:1.9.0.34 pkgsrc-2011Q3-base:1.9 pkgsrc-2011Q2:1.9.0.32 pkgsrc-2011Q2-base:1.9 pkgsrc-2011Q1:1.9.0.30 pkgsrc-2011Q1-base:1.9 pkgsrc-2010Q4:1.9.0.28 pkgsrc-2010Q4-base:1.9 pkgsrc-2010Q3:1.9.0.26 pkgsrc-2010Q3-base:1.9 pkgsrc-2010Q2:1.9.0.24 pkgsrc-2010Q2-base:1.9 pkgsrc-2010Q1:1.9.0.22 pkgsrc-2010Q1-base:1.9 pkgsrc-2009Q4:1.9.0.20 pkgsrc-2009Q4-base:1.9 pkgsrc-2009Q3:1.9.0.18 pkgsrc-2009Q3-base:1.9 pkgsrc-2009Q2:1.9.0.16 pkgsrc-2009Q2-base:1.9 pkgsrc-2009Q1:1.9.0.14 pkgsrc-2009Q1-base:1.9 pkgsrc-2008Q4:1.9.0.12 pkgsrc-2008Q4-base:1.9 pkgsrc-2008Q3:1.9.0.10 pkgsrc-2008Q3-base:1.9 cube-native-xorg:1.9.0.8 cube-native-xorg-base:1.9 pkgsrc-2008Q2:1.9.0.6 pkgsrc-2008Q2-base:1.9 cwrapper:1.9.0.4 pkgsrc-2008Q1:1.9.0.2 pkgsrc-2008Q1-base:1.9 pkgsrc-2007Q4:1.8.0.2 pkgsrc-2007Q4-base:1.8 pkgsrc-2007Q3:1.7.0.2 pkgsrc-2007Q3-base:1.7 pkgsrc-2007Q2:1.6.0.30 pkgsrc-2007Q2-base:1.6 pkgsrc-2007Q1:1.6.0.28 pkgsrc-2007Q1-base:1.6 pkgsrc-2006Q4:1.6.0.26 pkgsrc-2006Q4-base:1.6 pkgsrc-2006Q3:1.6.0.24 pkgsrc-2006Q3-base:1.6 pkgsrc-2006Q2:1.6.0.22 pkgsrc-2006Q2-base:1.6 pkgsrc-2006Q1:1.6.0.20 pkgsrc-2006Q1-base:1.6 pkgsrc-2005Q4:1.6.0.18 pkgsrc-2005Q4-base:1.6 pkgsrc-2005Q3:1.6.0.16 pkgsrc-2005Q3-base:1.6 pkgsrc-2005Q2:1.6.0.14 pkgsrc-2005Q2-base:1.6 pkgsrc-2005Q1:1.6.0.12 pkgsrc-2005Q1-base:1.6 pkgsrc-2004Q4:1.6.0.10 pkgsrc-2004Q4-base:1.6 pkgsrc-2004Q3:1.6.0.8 pkgsrc-2004Q3-base:1.6 pkgsrc-2004Q2:1.6.0.6 pkgsrc-2004Q2-base:1.6 pkgsrc-2004Q1:1.6.0.4 pkgsrc-2004Q1-base:1.6 pkgsrc-2003Q4:1.6.0.2 pkgsrc-2003Q4-base:1.6 netbsd-1-6-1:1.1.0.6 netbsd-1-6-1-base:1.1 netbsd-1-6:1.1.0.8 netbsd-1-6-RELEASE-base:1.1 pkgviews:1.1.0.4 pkgviews-base:1.1 buildlink2:1.1.0.2 buildlink2-base:1.1 netbsd-1-5-PATCH003:1.1; locks; strict; comment @# @; 1.11 date 2025.08.30.02.49.33; author tsutsui; state dead; branches; next 1.10; commitid 9ZvO2xCOirNvsH8G; 1.10 date 2018.05.06.14.32.06; author jmcneill; state Exp; branches; next 1.9; commitid S1C0JHjEw9HqgfBA; 1.9 date 2008.01.04.01.43.58; author pooka; state Exp; branches; next 1.8; 1.8 date 2007.11.28.22.33.18; author jnemeth; state Exp; branches; next 1.7; 1.7 date 2007.07.25.15.09.32; author xtraeme; state Exp; branches; next 1.6; 1.6 date 2003.11.10.23.53.32; author mrg; state Exp; branches; next 1.5; 1.5 date 2003.11.05.07.26.04; author mrg; state Exp; branches; next 1.4; 1.4 date 2003.11.01.09.25.31; author mycroft; state Exp; branches; next 1.3; 1.3 date 2003.11.01.04.03.18; author mrg; state Exp; branches; next 1.2; 1.2 date 2003.10.19.09.25.02; author agc; state Exp; branches; next 1.1; 1.1 date 2001.11.26.20.07.35; author wiz; state Exp; branches; next ; desc @@ 1.11 log @xbattbar: rename patches for maintainability, and misc cleanup. - add a valid MASTER_SITES - refer web.archive.org page for the latest HOMEPAGE - add LICENSE per COPYING file to appease pkglint @ text @$NetBSD: patch-ab,v 1.10 2018/05/06 14:32:06 jmcneill Exp $ --- xbattbar.c.orig 2001-02-02 05:25:29.000000000 +0000 +++ xbattbar.c @@@@ -27,6 +27,16 @@@@ static char *ReleaseVersion="1.4.2"; #include #include + +#ifdef __NetBSD__ +#define ENVSYSUNITNAMES +#include +#include +#include +#include +#include +#endif /* __NetBSD__ */ + #include #include #include @@@@ -577,33 +587,190 @@@@ void battery_check(void) #ifdef __NetBSD__ +#ifndef _NO_APM #include +#else +#define APM_AC_OFF 0x00 +#define APM_AC_ON 0x01 +#endif #define _PATH_APM_SOCKET "/var/run/apmdev" #define _PATH_APM_CTLDEV "/dev/apmctl" #define _PATH_APM_NORMAL "/dev/apm" +/* + * pre: fd contains a valid file descriptor of an envsys(4) supporting device + * && ns is the number of sensors + * && etds and ebis are arrays of sufficient size + * post: returns 0 and etds and ebis arrays are filled with sensor info + * or returns -1 on failure + */ +static int +fillsensors(int fd, envsys_tre_data_t *etds, envsys_basic_info_t *ebis, + size_t ns) +{ + int i; + + for (i = 0; i < ns; ++i) { + ebis[i].sensor = i; + if (ioctl(fd, ENVSYS_GTREINFO, &ebis[i]) == -1) { + warn("Can't get sensor info for sensor %d", i); + return 0; + } + + etds[i].sensor = i; + if (ioctl(fd, ENVSYS_GTREDATA, &etds[i]) == -1) { + warn("Can't get sensor data for sensor %d", i); + return 0; + } + } + return 1; +} + +/* + * pre: fd contains a valid file descriptor of an envsys(4) supporting device + * post: returns the number of valid sensors provided by the device + * or -1 on error + */ +static size_t +numsensors(int fd) +{ + int count = 0, valid = 1; + envsys_tre_data_t etd; + etd.sensor = 0; + + while (valid) { + if (ioctl(fd, ENVSYS_GTREDATA, &etd) == -1) + err(1, "Can't get sensor data"); + + valid = etd.validflags & ENVSYS_FVALID; + if (valid) + ++count; + + ++etd.sensor; + } + + return count; +} + +static envsys_tre_data_t *etds; +static envsys_basic_info_t *ebis; +static int *cetds; + +#if defined(_PATH_SYSMON) && __NetBSD_Version__ >= 106110000 +#define HAVE_NETBSD_ACPI +#endif + int first = 1; void battery_check(void) { int fd, r, p; +#ifndef _NO_APM struct apm_power_info info; +#endif + int acpi; + size_t ns; + size_t cc; + char *apmdev; + int i; + + acpi = 0; + apmdev = _PATH_APM_NORMAL; + if ((fd = open(apmdev, O_RDONLY)) == -1) { +#ifdef HAVE_NETBSD_ACPI + apmdev = _PATH_SYSMON; + fd = open(apmdev, O_RDONLY); + acpi = 1; +#endif + } + if (fd < 0) { + fprintf(stderr, "xbattbar: cannot open %s device\n", apmdev); + exit(1); + } - 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); } + if (first) { + cetds = (int *)malloc(ns * sizeof(int)); + etds = (envsys_tre_data_t *)malloc(ns * sizeof(envsys_tre_data_t)); + ebis = (envsys_basic_info_t *)malloc(ns * sizeof(envsys_basic_info_t)); + + if ((cetds == NULL) || (etds == NULL) || (ebis == NULL)) { + err(1, "Out of memory"); + } + } + + fillsensors(fd, etds, ebis, ns); + +#endif +#ifndef _NO_APM + } 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); } +#endif + } close(fd); ++elapsed_time; - /* get current remoain */ + if (acpi) { +#ifdef HAVE_NETBSD_ACPI + int32_t rtot = 0, maxtot = 0; + int have_pct = 0; + p = APM_AC_ON; + for (i = 0 ; i < ns ; i++) { + if ((etds[i].validflags & ENVSYS_FCURVALID) == 0) + continue; + cc = strlen(ebis[i].desc); + if (strncmp(ebis[i].desc, "acpibat", 7) == 0 && + (strcmp(&ebis[i].desc[cc - 7], " charge") == 0 || + strcmp(&ebis[i].desc[cc - 7], " energy") == 0)) { + rtot += etds[i].cur.data_s; + maxtot += etds[i].max.data_s; + } + /* + * XXX: We should use acpiacad driver and look for + * " connected", but that's broken on some machines + * and we want this to work everywhere. With this + * we will occasionally catch a machine conditioning + * a battery while connected, while other machines take + * 10-15 seconds to switch from "charging" to + * "discharging" and vice versa, but this is the best + * compromise. + */ + if ((ebis[i].units == ENVSYS_SWATTS || ebis[i].units == ENVSYS_SAMPS) && + etds[i].cur.data_s && + strncmp(ebis[i].desc, "acpibat", 7) == 0 && + strcmp(&ebis[i].desc[cc - 14], "discharge rate") == 0) { + p = APM_AC_OFF; + } + + if (ebis[i].units == ENVSYS_INTEGER && + strcmp(ebis[i].desc, "battery percent") == 0) { + have_pct = 1; + r = etds[i].cur.data_s; + } + if (ebis[i].units == ENVSYS_INDICATOR && + strcmp(ebis[i].desc, "ACIN present") == 0 && + etds[i].cur.data_s == 0) { + p = APM_AC_OFF; + } + } + if (!have_pct) + r = (rtot * 100.0) / maxtot; +#endif +#ifndef _NO_APM + } else { + /* get current remain */ if (info.battery_life > 100) { /* some APM BIOSes return values slightly > 100 */ r = 100; @@@@ -617,6 +784,8 @@@@ void battery_check(void) } else { p = APM_AC_OFF; } +#endif + } if (first || ac_line != p || battery_level != r) { first = 0; @ 1.10 log @Properly report battery and AC info from axppmic sensors. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.9 2008/01/04 01:43:58 pooka Exp $ @ 1.9 log @Make charging detection use discharge rate instead of charge rate, since a fully charged battery would sometimes drop the charge rate to 0. This happens at least on the submitter's and my laptops. patch from ymous anonimo @ text @d1 1 a1 1 $NetBSD$ d3 3 a5 3 --- xbattbar.c.orig 2001-02-02 07:25:29.000000000 +0200 +++ xbattbar.c 2008-01-04 03:32:10.000000000 +0200 @@@@ -27,6 +27,16 @@@@ d22 1 a22 1 @@@@ -577,33 +587,177 @@@@ d167 1 d195 11 d207 2 a208 1 + r = (rtot * 100.0) / maxtot; d216 1 a216 1 @@@@ -617,6 +771,8 @@@@ @ 1.8 log @PR/37442 - Jared D. McNeill -- xbattbar does not work on machines that have APM @ text @d3 3 a5 3 --- xbattbar.c.orig 2001-02-02 00:25:29.000000000 -0500 +++ xbattbar.c 2007-11-27 20:56:25.000000000 -0500 @@@@ -27,6 +27,14 @@@@ d15 2 d22 1 a22 1 @@@@ -577,33 +585,177 @@@@ d167 1 a167 1 + p = APM_AC_OFF; d188 1 a188 1 + if (ebis[i].units == ENVSYS_INDICATOR && d191 2 a192 2 + strcmp(&ebis[i].desc[cc - 8], "charging") == 0) { + p = APM_AC_ON; d203 1 a203 1 @@@@ -617,6 +769,8 @@@@ @ 1.7 log @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. @ text @d3 2 a4 2 --- xbattbar.c.orig 2001-02-02 06:25:29.000000000 +0100 +++ xbattbar.c 2007-07-25 17:03:43.000000000 +0200 d20 12 a31 1 @@@@ -583,27 +591,161 @@@@ d102 1 d104 1 d144 1 a144 1 d146 1 d148 1 a148 1 + d154 1 d195 1 d201 1 a201 1 @@@@ -617,6 +759,7 @@@@ d205 1 @ 1.6 log @rework the previous to not try to use _PATH_SYSMON if it isn't defined. fixes PR#23355 finally. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.5 2003/11/05 07:26:04 mrg Exp $ d3 2 a4 2 --- xbattbar.c.orig 2001-02-02 16:25:29.000000000 +1100 +++ xbattbar.c 2003-11-10 17:50:08.000000000 +1100 d20 1 a20 1 @@@@ -583,39 +591,174 @@@@ a91 4 - - if ((fd = open(_PATH_APM_NORMAL, O_RDONLY)) == -1) { - fprintf(stderr, "xbattbar: cannot open apm device\n"); - exit(1); d106 1 a106 4 } - - if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) { - fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n"); d109 2 a110 2 exit(1); } d112 2 a113 1 - close(fd); d118 2 a119 2 + exit(1); + } d129 1 a129 2 - ++elapsed_time; a131 4 - /* get current remoain */ - if (info.battery_life > 100) { - /* some APM BIOSes return values slightly > 100 */ - r = 100; d133 1 a133 2 } else { - r = info.battery_life; d136 3 a138 4 + if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) { + fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n"); + exit(1); + } d140 5 d146 1 a146 7 - /* get AC-line status */ - if (info.ac_state == APM_AC_ON) { - p = APM_AC_ON; + close(fd); + + ++elapsed_time; + d150 1 a150 1 + p = APM_AC_ON; d174 2 a175 2 + strcmp(&ebis[i].desc[cc - 11], "discharging") == 0) { + p = APM_AC_OFF; d180 6 d187 1 a187 15 - p = APM_AC_OFF; + /* 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; + } d189 1 d192 1 @ 1.5 log @revert part of the previous set of changes: acpiacad is broken on some machines so we can't use that to detect ac-power. for now, revert to what we were doing before. XXX perhaps acpiacad should be used if it exists, and if it doesn't fall XXX back to using "acpibat.*discharging". then people with broken acpiacad XXX can simply not include that driver in their kernel, but worry about XXX that again after pkgsrc freeze. also, check __NetBSD_Version__ to see when various envsys(4) API changes occured, and avoid using new methods on old systems. this should fix PR#23355. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.4 2003/11/01 09:25:31 mycroft Exp $ d4 1 a4 1 +++ xbattbar.c 2003-11-03 17:17:11.000000000 +1100 d20 1 a20 1 @@@@ -583,39 +590,171 @@@@ d92 4 d99 1 d101 1 a101 1 d103 2 a104 3 if ((fd = open(_PATH_APM_NORMAL, O_RDONLY)) == -1) { - fprintf(stderr, "xbattbar: cannot open apm device\n"); - exit(1); d106 2 a107 1 + fd = open(_PATH_SYSMON, O_RDONLY); d115 1 a115 1 + fprintf(stderr, "xbattbar: cannot open %s device\n", (acpi) ? _PATH_SYSMON : _PATH_APM_NORMAL); @ 1.4 log @More ACPI-related changes: * Recognize "charge" in addition to "energy". * Test ENVSYS_FCURVALID. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.3 2003/11/01 04:03:18 mrg Exp $ d4 2 a5 2 +++ xbattbar.c 2003-11-01 14:55:10.000000000 +1100 @@@@ -27,6 +27,13 @@@@ d12 1 d20 1 a20 1 @@@@ -583,46 +590,165 @@@@ d83 4 d100 2 d104 5 a108 1 + } d114 1 a114 3 - if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) { - fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n"); - exit(1); d116 1 d130 2 a131 1 + d133 8 a140 2 + + } else { d149 7 a155 11 close(fd); ++elapsed_time; - /* get current remoain */ - if (info.battery_life > 100) { - /* some APM BIOSes return values slightly > 100 */ - r = 100; - } else { - r = info.battery_life; - } d157 1 d159 1 a159 1 + p = APM_AC_OFF; d170 10 d182 3 a184 3 + strncmp(ebis[i].desc, "acpiacad", 8) == 0 && + strcmp(&ebis[i].desc[cc - 10], " connected") == 0) { + p = APM_AC_ON; d188 1 a188 10 + if (first || ac_line != p || battery_level != r) { + first = 0; + ac_line = p; + battery_level = r; + redraw(); + } - /* get AC-line status */ - if (info.ac_state == APM_AC_ON) { - p = APM_AC_ON; a190 7 - } - - if (first || ac_line != p || battery_level != r) { - first = 0; - ac_line = p; - battery_level = r; - redraw(); a204 7 + + if (first || ac_line != p || battery_level != r) { + first = 0; + ac_line = p; + battery_level = r; + redraw(); + } a205 1 } d207 1 @ 1.3 log @make xbattbar work in the presense of multiple acpibat's. also, note that we're not on AC power via the acpiacad's 'disconnected' entry, not one of the battery's "discharging" entries, as the latter may be true even while on AC power. @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.2 2003/10/19 09:25:02 agc Exp $ d19 1 a19 1 @@@@ -583,46 +590,161 @@@@ d145 1 a145 1 + p = APM_AC_ON; d147 2 d150 3 a152 1 + if (strcmp(&ebis[i].desc[cc - 6], "energy") == 0) { d159 2 a160 2 + strcmp(&ebis[i].desc[cc - 12], "disconnected") == 0) { + p = APM_AC_OFF; @ 1.2 log @Update xbattbar to 1.4.2nb3 by adding support for ACPI - if APM doesn't work, try to use ACPI to get the battery charge value, and AC charging switch. Known to work on my Sony VAIO (PCG-GRX315MP) with ACPI, and with thanks to: Lubomir Sedlacik for testing on an IBM T22 with ACPI Manuel Bouyer for testing on an IBM Thinkpad 600e with APM, and Brian A. Seklecki for testing on a Sony PCG-R505 @ text @d1 1 a1 1 $NetBSD: patch-ab,v 1.1 2001/11/26 20:07:35 wiz Exp $ d3 2 a4 2 --- xbattbar.c.orig 2001-02-02 05:25:29.000000000 +0000 +++ xbattbar.c 2003-10-17 13:15:51.000000000 +0100 d19 1 a19 1 @@@@ -583,46 +590,158 @@@@ d144 1 a144 1 + r = 0; d149 2 a150 1 + r = (etds[i].cur.data_s * 100.0) / etds[i].max.data_s; d154 2 a155 1 + strcmp(&ebis[i].desc[cc - 11], "discharging") == 0) { d159 1 @ 1.1 log @Add 'new' NetBSD-apm support, based on patch from Love in pkg/14554. Bump version to 1.4.2nb1. @ text @d1 1 a1 1 $NetBSD$ d3 97 a99 3 --- xbattbar.c.orig Fri Feb 2 06:25:29 2001 +++ xbattbar.c @@@@ -594,6 +594,7 @@@@ d103 97 a199 4 + memset(&info, 0, sizeof(info)); if (ioctl(fd, APM_IOC_GETPOWER, &info) != 0) { fprintf(stderr, "xbattbar: ioctl APM_IOC_GETPOWER failed\n"); exit(1); @