From owner-freebsd-mobile@FreeBSD.ORG Thu Mar 27 03:42:52 2008 Return-Path: Delivered-To: freebsd-mobile@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B335E106564A for ; Thu, 27 Mar 2008 03:42:52 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [64.174.51.43]) by mx1.freebsd.org (Postfix) with ESMTP id 860B68FC18 for ; Thu, 27 Mar 2008 03:42:52 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from server2.ambrisko.com (HELO www.ambrisko.com) ([192.168.1.2]) by ironport2.ambrisko.com with ESMTP; 26 Mar 2008 20:07:10 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.14.1/8.12.11) with ESMTP id m2R3E7Nb087985; Wed, 26 Mar 2008 19:14:07 -0800 (PST) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.14.1/8.13.1/Submit) id m2R3E7TW087984; Wed, 26 Mar 2008 20:14:07 -0700 (PDT) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200803270314.m2R3E7TW087984@ambrisko.com> In-Reply-To: <0319208F-8098-4EAA-B3DA-22C6FE1C02DD@langille.org> To: Dan Langille Date: Wed, 26 Mar 2008 20:14:07 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Cc: freebsd-mobile@freebsd.org Subject: Re: battery monitor with KDE 64 bit X-BeenThere: freebsd-mobile@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Mobile computing with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Mar 2008 03:42:52 -0000 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 ++#include ++/* + # include + # 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.