Re: battery monitor with KDE 64 bit

Doug Ambrisko <[email protected]>
Newsgroups gmane.os.freebsd.devel.mobile
Message-ID <[email protected]>
Dan Langille writes:
| I'm running 7.0 amd64 with KDE 3.5
| 
| sysutils/klaptopdaemon works only on i386
| 
| What battery monitor software are you using?

Try to convert it from APM to ACPI.  This patch to sysutils/xbatt
works for me on both i386/amd64.

Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/xbatt/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- Makefile	19 May 2007 20:23:41 -0000	1.15
+++ Makefile	27 Mar 2008 03:07:19 -0000
@@ -14,7 +14,7 @@ MASTER_SITES=	http://www.clave.gr.jp/~et
 MAINTAINER=	[email protected]
 COMMENT=	Laptop battery status display for X11
 
-ONLY_FOR_ARCHS=	i386
+ONLY_FOR_ARCHS=	i386 amd64
 
 USE_IMAKE=	yes
 USE_XPM=	yes
--- /dev/null	2008-03-26 20:00:00.000000000 -0700
+++ files/patch-acpi	2007-03-21 15:06:19.000000000 -0700
@@ -0,0 +1,69 @@
+--- xbatt.c.orig	Wed Mar 21 14:21:28 2007
++++ xbatt.c	Wed Mar 21 15:05:10 2007
+@@ -60,9 +60,13 @@
+ #endif
+ 
+ #ifdef __FreeBSD__
++#include <sys/types.h>
++#include <sys/sysctl.h>
++/*
+ # include <machine/apm_bios.h>
+ # define APMDEV21	"/dev/apm0"
+ # define APMDEV22	"/dev/apm"
++*/
+ #endif
+ 
+ #include "pixmaps/battery.xpm"
+@@ -185,6 +189,7 @@ main(
+     XtAppContext appContext;
+ 
+ #if !defined(NOAPM) && defined(__FreeBSD__)
++#if DJA
+     /* initialize APM Interface */
+     if ((apmfd = open(APMDEV21, O_RDWR)) == -1) {
+ 	if ((apmfd = open(APMDEV22, O_RDWR)) == -1) {
+@@ -194,6 +199,7 @@ main(
+ 	}
+     }
+ #endif
++#endif
+ 
+     /* start X-Window session */
+     XtSetLanguageProc( NULL, NULL, NULL );
+@@ -317,6 +323,7 @@ struct status getBatteryStatus()
+ {
+     struct status	ret;
+ #ifdef	__FreeBSD__
++#if DJA
+     struct apm_info	info;
+ 
+ #ifndef NOAPM
+@@ -370,6 +377,28 @@ struct status getBatteryStatus()
+ 	ret.charge = APM_STAT_BATT_HIGH;	/* I only want to know,	*/
+ 						/* chrging or not.	*/
+     }
++#else
++    int remain, charge, len, error, junk;
++
++    bzero(&ret, sizeof(ret));
++    len = sizeof(remain);
++    error = sysctlbyname("hw.acpi.battery.life",
++		   &remain, &len, NULL, 0);
++    if (error == 0)
++	    remain == 0;
++
++    len = sizeof(charge);
++    error = sysctlbyname("hw.acpi.battery.state",
++		   &charge, &len, NULL, 0);
++    if (error == 0 && charge == 0) {
++	ret.acline = APM_STAT_LINE_ON;
++	ret.charge = APM_STAT_BATT_CHARGING;
++    } else {
++	ret.acline = APM_STAT_LINE_OFF;
++	ret.charge = APM_STAT_BATT_HIGH;
++    }
++    ret.remain = remain;
++#endif
+ #endif	/* FreeBSD */
+ 
+ #ifdef	__linux__

The #if DJA can be removed.  I left it in to compare the old and
new code.  If this seems to be a reasonable approach then I can
remove the DJA part and send it to the maintainer.

Doug A.

Doug A.
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-mobile
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.