Date: Wed, 26 Mar 2008 20:14:07 -0700 (PDT) From: Doug Ambrisko <ambrisko@ambrisko.com> To: Dan Langille <dan@langille.org> Cc: freebsd-mobile@freebsd.org Subject: Re: battery monitor with KDE 64 bit Message-ID: <200803270314.m2R3E7TW087984@ambrisko.com> In-Reply-To: <0319208F-8098-4EAA-B3DA-22C6FE1C02DD@langille.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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= nobu@psrc.isac.co.jp 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803270314.m2R3E7TW087984>