From owner-freebsd-ports-bugs@FreeBSD.ORG Mon Mar 21 10:50:01 2011 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB19C106566C for ; Mon, 21 Mar 2011 10:50:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 7A2248FC12 for ; Mon, 21 Mar 2011 10:50:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p2LAo1Uw074816 for ; Mon, 21 Mar 2011 10:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p2LAo177074815; Mon, 21 Mar 2011 10:50:01 GMT (envelope-from gnats) Resent-Date: Mon, 21 Mar 2011 10:50:01 GMT Resent-Message-Id: <201103211050.p2LAo177074815@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, John Marshall Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 22342106567F for ; Mon, 21 Mar 2011 10:47:58 +0000 (UTC) (envelope-from john.marshall@riverwillow.com.au) Received: from mail1.riverwillow.net.au (mail1.riverwillow.net.au [203.58.93.36]) by mx1.freebsd.org (Postfix) with ESMTP id B604A8FC14 for ; Mon, 21 Mar 2011 10:47:57 +0000 (UTC) Received: from rwpc08.mby-g.riverwillow.net.au (rwpc08.mby-g.riverwillow.net.au [192.168.25.71]) (authenticated bits=0) by mail1.riverwillow.net.au (8.14.4/8.14.4) with ESMTP id p2LAWmcg009756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Mar 2011 21:32:49 +1100 (AEDT) Received: from rwpc08.mby-g.riverwillow.net.au (localhost [127.0.0.1]) by rwpc08.mby-g.riverwillow.net.au (8.14.4/8.14.4/Submit) with ESMTP id p2LAWmvW026051 for ; Mon, 21 Mar 2011 21:32:48 +1100 (AEDT) (envelope-from john.marshall@riverwillow.com.au) Received: (from john@localhost) by rwpc08.mby-g.riverwillow.net.au (8.14.4/8.14.4/Submit) id p2LAWmPa026050; Mon, 21 Mar 2011 21:32:48 +1100 (AEDT) (envelope-from john) Message-Id: <201103211032.p2LAWmPa026050@rwpc08.mby-g.riverwillow.net.au> Date: Mon, 21 Mar 2011 21:32:48 +1100 (AEDT) From: John Marshall To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: ports/155745: [patch] sysutils/xfce4-battery-plugin 1.0.0 always shows 0% for ACPI battery X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John Marshall List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Mar 2011 10:50:01 -0000 >Number: 155745 >Category: ports >Synopsis: [patch] sysutils/xfce4-battery-plugin 1.0.0 always shows 0% for ACPI battery >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 21 10:50:01 UTC 2011 >Closed-Date: >Last-Modified: >Originator: John Marshall >Release: FreeBSD 8.2-RELEASE i386 >Organization: Riverwillow Pty Ltd >Environment: System: FreeBSD rwpc08 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 09:28:08 AEDT 2011 root@rwpc08:/build/obj/usr/src/sys/RWPC08 i386 >Description: There is an outstanding bug in the plugin source which results in ACPI batteries on FreeBSD always showing 0%. The previous version of the port included a patch to address this, but that was sent to the attic with the 1.0.0 update. Some years ago, two patches were submitted to the Xfce folks but insufficient testers were available to convince the developers to commit. I took what looks to be the preferred patch (submitted by Shigeru Fujiwara on 2007-01-28) and realigned it to suit the current version of the source file. It "works for me" on FreeBSD/i386 8.2 and Xfce 4.8.0. >How-To-Repeat: >Fix: - Modify Makefile: Bump PORTREVISION - Add files/patch-panel-plugin_libacpi.c --- xfce4-battery-plugin.diff begins here --- diff -urN sysutils/xfce4-battery-plugin.orig/Makefile sysutils/xfce4-battery-plugin/Makefile --- sysutils/xfce4-battery-plugin.orig/Makefile 2011-03-19 18:31:38.000000000 +1100 +++ sysutils/xfce4-battery-plugin/Makefile 2011-03-21 19:55:10.000000000 +1100 @@ -7,6 +7,7 @@ PORTNAME= xfce4-battery-plugin PORTVERSION= 1.0.0 +PORTREVISION= 1 CATEGORIES= sysutils xfce MASTER_SITES= ${MASTER_SITE_XFCE} MASTER_SITE_SUBDIR=/src/panel-plugins/${PORTNAME}/${PORTVERSION:R} diff -urN sysutils/xfce4-battery-plugin.orig/files/patch-panel-plugin_libacpi.c sysutils/xfce4-battery-plugin/files/patch-panel-plugin_libacpi.c --- sysutils/xfce4-battery-plugin.orig/files/patch-panel-plugin_libacpi.c 1970-01-01 10:00:00.000000000 +1000 +++ sysutils/xfce4-battery-plugin/files/patch-panel-plugin_libacpi.c 2011-03-21 19:35:31.000000000 +1100 @@ -0,0 +1,82 @@ +--- panel-plugin/libacpi.c.orig 2011-01-03 23:38:40.000000000 +1100 ++++ panel-plugin/libacpi.c 2011-03-21 15:38:01.000000000 +1100 +@@ -30,6 +30,16 @@ + #include + #include + ++#ifdef __FreeBSD__ ++#include ++#include ++#include ++#define ACPIDEV "/dev/acpi" ++static int acpifd; ++#define UNKNOWN_CAP 0xffffffff ++#define UNKNOWN_VOLTAGE 0xffffffff ++#endif ++ + #if HAVE_SYSCTL + + #if defined(__NetBSD__) || defined (__OpenBSD__) +@@ -484,6 +494,7 @@ + } + + return 1; ++ + #else + #ifdef HAVE_SYSCTL + static char buf[BUFSIZ]; +@@ -730,6 +741,24 @@ + #endif + } + acpiinfo->present = retval; ++ ++#ifdef __FreeBSD__ ++ union acpi_battery_ioctl_arg battio; ++ acpifd = open(ACPIDEV, O_RDONLY); ++ ++ battio.unit = battery; ++ if (ioctl(acpifd, ACPIIO_BATT_GET_BIF, &battio) == -1) { ++ return 0; ++ } ++ close(acpifd); ++ ++ acpiinfo->design_capacity = battio.bif.dcap; ++ acpiinfo->last_full_capacity = battio.bif.lfcap; ++ acpiinfo->battery_technology = battio.bif.btech; ++ acpiinfo->design_voltage = battio.bif.dvol; ++ acpiinfo->design_capacity_warning = battio.bif.wcap; ++ acpiinfo->design_capacity_low = battio.bif.lcap; ++#endif + return 1; + #else + return 0; +@@ -966,6 +995,29 @@ + #endif + } + acpistate->percentage =retval; ++ ++#ifdef __FreeBSD__ ++ union acpi_battery_ioctl_arg battio; ++ acpifd = open(ACPIDEV, O_RDONLY); ++ ++ battio.unit = battery; ++ if (ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) == -1) { ++ return 0; ++ } ++ ++ acpistate->state = battio.battinfo.state; ++ acpistate->prate = battio.battinfo.rate; ++ acpistate->rcapacity = acpiinfo->last_full_capacity * battio.battinfo.cap / 100; ++ acpistate->rtime = battio.battinfo.min; ++ acpistate->percentage = battio.battinfo.cap; ++ ++ battio.unit = battery; ++ if (ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) == -1) { ++ return 0; ++ } ++ close(acpifd); ++ acpistate->pvoltage = battio.bst.volt; ++#endif + return 1; + #else + return 0; --- xfce4-battery-plugin.diff ends here --- >Release-Note: >Audit-Trail: >Unformatted: