aboutsummaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorMunechika SUMIKAWA <sumikawa@FreeBSD.org>2006-12-14 01:59:53 +0000
committerMunechika SUMIKAWA <sumikawa@FreeBSD.org>2006-12-14 01:59:53 +0000
commit6de0e5d87a28cee07352a1ffe7ca107016ac3997 (patch)
tree307a862748183c2ff24734e86173933b1e38ee7f /sysutils
parent4dd5345bd168208f5fd4d60a590b3ee060aa5462 (diff)
downloadports-6de0e5d87a28cee07352a1ffe7ca107016ac3997.tar.gz
ports-6de0e5d87a28cee07352a1ffe7ca107016ac3997.zip
Notes
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/xbattbar/Makefile4
-rw-r--r--sysutils/xbattbar/files/patch-ab13
-rw-r--r--sysutils/xbattbar/files/patch-xbattbar.c140
3 files changed, 141 insertions, 16 deletions
diff --git a/sysutils/xbattbar/Makefile b/sysutils/xbattbar/Makefile
index 305876d8e948..1b1ad059b204 100644
--- a/sysutils/xbattbar/Makefile
+++ b/sysutils/xbattbar/Makefile
@@ -7,7 +7,7 @@
PORTNAME= xbattbar
PORTVERSION= 1.4.2
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= sysutils
MASTER_SITES= http://iplab.aist-nara.ac.jp/member/suguru/
DISTNAME= ${PORTNAME}_${PORTVERSION}
@@ -15,8 +15,6 @@ DISTNAME= ${PORTNAME}_${PORTVERSION}
MAINTAINER= sumikawa@FreeBSD.org
COMMENT= Simple battery meter
-ONLY_FOR_ARCHS= i386
-
USE_IMAKE= yes
USE_X_PREFIX= yes
WRKSRC= ${WRKDIR}/xbattbar-${PORTVERSION}
diff --git a/sysutils/xbattbar/files/patch-ab b/sysutils/xbattbar/files/patch-ab
index a911d7528037..e69de29bb2d1 100644
--- a/sysutils/xbattbar/files/patch-ab
+++ b/sysutils/xbattbar/files/patch-ab
@@ -1,13 +0,0 @@
---- xbattbar.c.old Mon Dec 31 03:32:04 2001
-+++ xbattbar.c Mon Dec 31 03:32:08 2001
-@@ -522,8 +522,8 @@
- int fd, r, p;
- struct apm_info info;
-
-- if ((fd = open(APMDEV21, O_RDWR)) == -1 &&
-- (fd = open(APMDEV22, O_RDWR)) == -1) {
-+ if ((fd = open(APMDEV21, O_RDONLY)) == -1 &&
-+ (fd = open(APMDEV22, O_RDONLY)) == -1) {
- fprintf(stderr, "xbattbar: cannot open apm device\n");
- exit(1);
- }
diff --git a/sysutils/xbattbar/files/patch-xbattbar.c b/sysutils/xbattbar/files/patch-xbattbar.c
new file mode 100644
index 000000000000..3b26d420158e
--- /dev/null
+++ b/sysutils/xbattbar/files/patch-xbattbar.c
@@ -0,0 +1,140 @@
+--- xbattbar.c.orig Fri Feb 2 13:25:29 2001
++++ xbattbar.c Wed Dec 13 00:35:49 2006
+@@ -501,6 +501,10 @@
+
+ #ifdef __FreeBSD__
+
++#include <sys/types.h>
++#include <sys/sysctl.h>
++
++#if defined(__i386__)
+ #include <machine/apm_bios.h>
+
+ #define APMDEV21 "/dev/apm0"
+@@ -515,54 +519,90 @@
+ #define APM_STAT_BATT_LOW 1
+ #define APM_STAT_BATT_CRITICAL 2
+ #define APM_STAT_BATT_CHARGING 3
++#endif /* i386 */
+
+ int first = 1;
+ void battery_check(void)
+ {
+- int fd, r, p;
+- struct apm_info info;
++ int r, p;
++ static int sysctl = 1;
+
+- if ((fd = open(APMDEV21, O_RDWR)) == -1 &&
+- (fd = open(APMDEV22, O_RDWR)) == -1) {
+- fprintf(stderr, "xbattbar: cannot open apm device\n");
+- exit(1);
+- }
+- if (ioctl(fd, APMIO_GETINFO, &info) == -1) {
+- fprintf(stderr, "xbattbar: ioctl APMIO_GETINFO failed\n");
+- exit(1);
++ if (sysctl) {
++ size_t r_size, p_size;
++
++ /* get current status */
++ r_size = sizeof(r);
++ if (sysctl && sysctlbyname("hw.acpi.battery.life", &r, &r_size, NULL, 0) == -1) {
++#if defined(__i386__)
++ fprintf(stderr, "xbattbar: fall back to apm interface\n");
++ sysctl = 0;
++#else /* !i386 */
++ fprintf(stderr, "xbattbar: can not get battery status\n");
++ exit(1);
++#endif /* i386 */
++ }
++
++ /* get AC-line status */
++ p_size = sizeof(p);
++ if (sysctl && sysctlbyname("hw.acpi.acline", &p, &p_size, NULL, 0) == -1) {
++#if defined(__i386__)
++ fprintf(stderr, "xbattbar: fall back to apm interface\n");
++ sysctl = 0;
++#else /* !i386 */
++ fprintf(stderr, "xbattbar: can not get AC-line status\n");
++ exit(1);
++#endif /* i386 */
++ }
+ }
+- close (fd);
+
+- ++elapsed_time;
++#if defined(__i386__)
++ if (!sysctl) {
++ int fd;
++ struct apm_info info;
++
++ if ((fd = open(APMDEV21, O_RDONLY)) == -1 &&
++ (fd = open(APMDEV22, O_RDONLY)) == -1) {
++ fprintf(stderr, "xbattbar: cannot open apm device\n");
++ exit(1);
++ }
++ if (ioctl(fd, APMIO_GETINFO, &info) == -1) {
++ fprintf(stderr, "xbattbar: ioctl APMIO_GETINFO failed\n");
++ exit(1);
++ }
++ close (fd);
+
+- /* get current status */
+- if (info.ai_batt_life == APM_STAT_UNKNOWN) {
+- switch (info.ai_batt_stat) {
+- case APM_STAT_BATT_HIGH:
+- r = 100;
+- break;
+- case APM_STAT_BATT_LOW:
+- r = 40;
+- break;
+- case APM_STAT_BATT_CRITICAL:
+- r = 10;
+- break;
+- default: /* expected to be APM_STAT_UNKNOWN */
++ /* get current status */
++ if (info.ai_batt_life == APM_STAT_UNKNOWN) {
++ switch (info.ai_batt_stat) {
++ case APM_STAT_BATT_HIGH:
++ r = 100;
++ break;
++ case APM_STAT_BATT_LOW:
++ r = 40;
++ break;
++ case APM_STAT_BATT_CRITICAL:
++ r = 10;
++ break;
++ default: /* expected to be APM_STAT_UNKNOWN */
++ r = 100;
++ }
++ } else if (info.ai_batt_life > 100) {
++ /* some APM BIOSes return values slightly > 100 */
+ r = 100;
++ } else {
++ r = info.ai_batt_life;
+ }
+- } else if (info.ai_batt_life > 100) {
+- /* some APM BIOSes return values slightly > 100 */
+- r = 100;
+- } else {
+- r = info.ai_batt_life;
+- }
+
+- /* get AC-line status */
+- if (info.ai_acline == APM_STAT_LINE_ON) {
+- p = APM_STAT_LINE_ON;
+- } else {
+- p = APM_STAT_LINE_OFF;
++ /* get AC-line status */
++ if (info.ai_acline == APM_STAT_LINE_ON) {
++ p = APM_STAT_LINE_ON;
++ } else {
++ p = APM_STAT_LINE_OFF;
++ }
+ }
++#endif /* i386 */
++
++ ++elapsed_time;
+
+ if (first || ac_line != p || battery_level != r) {
+ first = 0;