aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils
diff options
context:
space:
mode:
authormiwi <miwi@FreeBSD.org>2011-03-27 18:36:11 +0800
committermiwi <miwi@FreeBSD.org>2011-03-27 18:36:11 +0800
commit33b2e76cd4eb3cc71c3554816c2d54b35cc72b2e (patch)
treef7782cf294271c1f4df0a8127148bf47f3081ea8 /sysutils
parenta0950f34f079a7734bc9d655f4a6486c6df61894 (diff)
downloadfreebsd-ports-gnome-33b2e76cd4eb3cc71c3554816c2d54b35cc72b2e.tar.gz
freebsd-ports-gnome-33b2e76cd4eb3cc71c3554816c2d54b35cc72b2e.tar.zst
freebsd-ports-gnome-33b2e76cd4eb3cc71c3554816c2d54b35cc72b2e.zip
- Fix Battery Status
PR: 155745 Submitted by: John Marshall <john.marshall@riverwillow.com.au>
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/xfce4-battery-plugin/Makefile1
-rw-r--r--sysutils/xfce4-battery-plugin/files/patch-panel-plugin_libacpi.c82
2 files changed, 83 insertions, 0 deletions
diff --git a/sysutils/xfce4-battery-plugin/Makefile b/sysutils/xfce4-battery-plugin/Makefile
index 267c428a3fcf..9664c6894549 100644
--- a/sysutils/xfce4-battery-plugin/Makefile
+++ b/sysutils/xfce4-battery-plugin/Makefile
@@ -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 --git a/sysutils/xfce4-battery-plugin/files/patch-panel-plugin_libacpi.c b/sysutils/xfce4-battery-plugin/files/patch-panel-plugin_libacpi.c
new file mode 100644
index 000000000000..b9109422b000
--- /dev/null
+++ b/sysutils/xfce4-battery-plugin/files/patch-panel-plugin_libacpi.c
@@ -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 <dirent.h>
+ #include <glob.h>
+
++#ifdef __FreeBSD__
++#include <fcntl.h>
++#include <sys/ioctl.h>
++#include <dev/acpica/acpiio.h>
++#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;