summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Mende <angelos@gentoo.org>2008-08-21 21:35:51 +0000
committerChristoph Mende <angelos@gentoo.org>2008-08-21 21:35:51 +0000
commit5392a45b6016527ab8300219c90be072d657e99e (patch)
tree21d496a690cf2a680eef5a6b07d3e57ebaf9d5a3 /xfce-extra
parentversion bump (diff)
downloadhistorical-5392a45b6016527ab8300219c90be072d657e99e.tar.gz
historical-5392a45b6016527ab8300219c90be072d657e99e.tar.bz2
historical-5392a45b6016527ab8300219c90be072d657e99e.zip
Using sysfs instead of proc, bug 219690
Package-Manager: portage-2.2_rc8/cvs/Linux 2.6.26-gentoo x86_64
Diffstat (limited to 'xfce-extra')
-rw-r--r--xfce-extra/xfce4-battery/ChangeLog8
-rw-r--r--xfce-extra/xfce4-battery/Manifest14
-rw-r--r--xfce-extra/xfce4-battery/files/xfce4-battery-0.5.0-sysfs.patch356
-rw-r--r--xfce-extra/xfce4-battery/xfce4-battery-0.5.0-r3.ebuild33
4 files changed, 409 insertions, 2 deletions
diff --git a/xfce-extra/xfce4-battery/ChangeLog b/xfce-extra/xfce4-battery/ChangeLog
index eaa74d81dbd7..5da62df6a7b6 100644
--- a/xfce-extra/xfce4-battery/ChangeLog
+++ b/xfce-extra/xfce4-battery/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for xfce-extra/xfce4-battery
# Copyright 2000-2008 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/xfce-extra/xfce4-battery/ChangeLog,v 1.60 2008/04/25 16:03:10 drac Exp $
+# $Header: /var/cvsroot/gentoo-x86/xfce-extra/xfce4-battery/ChangeLog,v 1.61 2008/08/21 21:35:51 angelos Exp $
+
+*xfce4-battery-0.5.0-r3 (21 Aug 2008)
+
+ 21 Aug 2008; Christoph Mende <angelos@gentoo.org>
+ +files/xfce4-battery-0.5.0-sysfs.patch, +xfce4-battery-0.5.0-r3.ebuild:
+ Using sysfs instead of proc, bug 219690
25 Apr 2008; Samuli Suominen <drac@gentoo.org>
xfce4-battery-0.5.0-r2.ebuild:
diff --git a/xfce-extra/xfce4-battery/Manifest b/xfce-extra/xfce4-battery/Manifest
index b2adb20d9126..95a6837c7927 100644
--- a/xfce-extra/xfce4-battery/Manifest
+++ b/xfce-extra/xfce4-battery/Manifest
@@ -1,8 +1,20 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
AUX xfce4-battery-0.5.0-2.6.21.patch 738 RMD160 0e6f30e886f4e5a51835475d25188f5fd9d60a3e SHA1 c011b637f5d32c4c692e77f659caf287e33f827c SHA256 ea2f0220d6505615b27dd200b87ff99fc767606ec95e0c32cee82872c5a04d8b
AUX xfce4-battery-0.5.0-2.6.24-headers.patch 422 RMD160 f8d0895dfef8b67569fcc253f2cde2330bfe89e7 SHA1 a8818bd9111dd0feca524244ca3504d8475396df SHA256 c44e0db7010b12b9de40c4072b84088761e5b1f08775445eaa6d6bbca242680d
AUX xfce4-battery-0.5.0-freebsd.patch 675 RMD160 f670161edade82ecf78aee3ef9da0e230a667cd6 SHA1 a5bd15629095e7cd922c3550ff01d6332d7b463d SHA256 7dee4e6556334cd985e69e70992719f7fca21dce3bed75b8780153fddda1a175
AUX xfce4-battery-0.5.0-libacpi.patch 1505 RMD160 709bd01ddbbfb2bf117d0e87d0642c463676c167 SHA1 e14de88cab52ed6e6146122f9997b8b93b3a301e SHA256 1f49924a10c5e53f88912db3e63dc382052e68fdd4c1ea439771a504f5f08566
+AUX xfce4-battery-0.5.0-sysfs.patch 8838 RMD160 3295285f56473996c168cc0a265714f134c359c2 SHA1 1573a3269045cf8baa73bf156d49bd9f3a09bdb2 SHA256 725692d98eead435099e6a27f527523d4984c792751379d7b9b501be04072e39
DIST xfce4-battery-plugin-0.5.0.tar.bz2 222269 RMD160 bbf64994c7686b11b6a51bd7728569cd2a5d9777 SHA1 63439d32bfe8411458d41c38824cb393bc31d6e0 SHA256 4428f2fe1f5f28e6cc711278fd9c5c90f325cf0c5298f98a5d60940116cbcef8
EBUILD xfce4-battery-0.5.0-r2.ebuild 918 RMD160 7686da7d9fc949456a70c296300d5c85b43ca3de SHA1 ab0f06db5e9a9cd44289f89bfcc5181bba62787a SHA256 446fa8bec61bef37dbbd2c19ba488fc5de90b410e2aaccf45cce3b74b13cc11f
-MISC ChangeLog 8359 RMD160 5e15aaa6c77f9f23ea9a59b012616ef433bb0197 SHA1 db6b7bae0370e2aa856a7e3b76337d07acfc1e1a SHA256 ed7552af4d8c49e2060b15638f00a2cc66ee4e3dd5ed5b5ae38060306081e0de
+EBUILD xfce4-battery-0.5.0-r3.ebuild 960 RMD160 48e343884b022ae112b23f86e09782559116327d SHA1 1fe96878c91abf8ee36af156e9b1fea6ce3ff337 SHA256 70130548405145e685505244fb8ff393209807a5b1831594af1935441b02b7e7
+MISC ChangeLog 8570 RMD160 41b6ddb49068d4a1fdc1204410656a31e8092193 SHA1 cbf7e0b711ee6947a2fd4c738ff93b2ea8f06aad SHA256 a0191e9dbefaae346b0116184c2a17d9c7c94ece462551ae5c991a82cde05cb3
MISC metadata.xml 157 RMD160 d7470fe88d1b96f3a7f1ef26fb7dc646b4a1b907 SHA1 7eae91f2588bdae8667d37a98fb3090d539eeca1 SHA256 44350daa7594842894d676413708d8ea77ccb0017bed24711af5b256281f5e61
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v2.0.9 (GNU/Linux)
+
+iEYEARECAAYFAkit39sACgkQKhnDs22gwa9l3QCfd6fHmbf7IqqbLpoCwX6Zszpm
+zWEAnjsSvzwcMIWtRZA1UBPTdSQOEB8o
+=imHH
+-----END PGP SIGNATURE-----
diff --git a/xfce-extra/xfce4-battery/files/xfce4-battery-0.5.0-sysfs.patch b/xfce-extra/xfce4-battery/files/xfce4-battery-0.5.0-sysfs.patch
new file mode 100644
index 000000000000..640048f519f1
--- /dev/null
+++ b/xfce-extra/xfce4-battery/files/xfce4-battery-0.5.0-sysfs.patch
@@ -0,0 +1,356 @@
+diff -ru xfce4-battery-plugin-0.5.0.orig/panel-plugin/libacpi.c xfce4-battery-plugin-0.5.0-fixed/panel-plugin/libacpi.c
+--- xfce4-battery-plugin-0.5.0.orig/panel-plugin/libacpi.c 2008-04-06 02:56:10.502679698 +0200
++++ xfce4-battery-plugin-0.5.0-fixed/panel-plugin/libacpi.c 2008-04-06 03:15:11.306678469 +0200
+@@ -54,6 +54,10 @@
+
+ static char batteries[MAXBATT][128];
+ static char battinfo[MAXBATT][128];
++/* path to AC adapter because not all AC adapter are listed
++in /sys/class/power_supply/AC/ this obviously only supports one AC adapter. */
++static char sysfsacdir[128];
++
+ #ifndef __linux__
+ #if HAVE_SYSCTL
+ static int
+@@ -181,9 +185,76 @@
+ #endif
+ #endif
+
++int check_acpi_sysfs(void)
++{
++ DIR *sysfs;
++ struct dirent *batt;
++ char *name;
++ FILE *typefile;
++ char typepath[128];
++ char tmptype[8];
++
++ sysfs = opendir("/sys/class/power_supply");
++ if (sysfs == 0)
++ {
++ #ifdef DEBUG
++ printf("DBG:No acpi support for sysfs. Trying procfs...\n");
++ #endif
++ return 2;
++ }
++
++ while ((batt = readdir(sysfs)))
++ {
++ name = batt->d_name;
++ if (!strncmp(".", name, 1)) continue;
++ /* check whether /sys/class/power_supply/$name/type exists and
++ contains "Battery" or "Mains" */
++ sprintf(typepath, "/sys/class/power_supply/%s/type",name);
++ if(!(typefile = fopen(typepath, "r"))) continue;
++ fgets(tmptype, 8, typefile);
++ fclose(typefile);
++ if(strncmp("Battery", tmptype, 7)==0)
++ {
++ sprintf(batteries[batt_count], "/sys/class/power_supply/%s", name);
++ #ifdef DEBUG
++ printf("DBG:battery number %d at:\n",batt_count);
++ printf("DBG:sysfs dir->%s\n",batteries[batt_count]);
++ printf("DBG:------------------------\n");
++ #endif
++ batt_count++;
++ }
++ /* I guess that the type of the AC adapter is always "Mains" (?) */
++ else if(strncmp("Mains", tmptype, 5)==0){
++ sprintf(sysfsacdir, "/sys/class/power_supply/%s", name);
++ #ifdef DEBUG
++ printf("DBG:sysfs AC dir->%s\n",sysfsacdir);
++ printf("DBG:------------------------\n");
++ #endif
++ }
++ }
++ closedir(sysfs);
++ if ( batt_count == 0 )
++ {
++#ifdef DEBUG
++ printf("DBG:No acpi support for sysfs. Trying procfs...\n");
++#endif
++ acpi_sysfs = 0;
++ return 2;
++ }
++ else
++ {
++ acpi_sysfs = 1;
++ return 0;
++ }
++}
++
+ /* see if we have ACPI support */
+ int check_acpi(void)
+ {
++#ifdef __linux__
++ if ( check_acpi_sysfs() == 0 )
++ return 0;
++#endif
+ DIR *battdir;
+ struct dirent *batt;
+ char *name;
+@@ -262,9 +333,82 @@
+ #endif
+ }
+
++int read_sysfs_int(char* filename)
++{
++ FILE* f;
++ f = fopen(filename,"r");
++ if ( !f )
++ {
++#ifdef DEBUG
++ printf("DBG:Could not open %s\n",filename);
++#endif
++ return 0;
++ }
++ int out;
++ fscanf(f,"%d",&out);
++ fclose(f);
++ return out;
++}
++
++char* read_sysfs_string(char* filename)
++{
++ FILE* f;
++ f = fopen(filename,"r");
++ if ( !f )
++ {
++#ifdef DEBUG
++ printf("DBG:Could not open %s\n",filename);
++#endif
++ return NULL;
++ }
++ fscanf(f,"%s",buf2);
++ fclose(f);
++ return buf2;
++}
++
++int read_acad_state_sysfs(void)
++{
++ DIR *sysfs;
++ struct dirent *propety;
++ char *name;
++ char onlinefilepath[128];
++
++ sysfs = opendir(sysfsacdir);
++ if (sysfs == 0)
++ {
++ #ifdef DEBUG
++ printf("DBG:Can't open %s",sysfsacdir);
++ #endif
++ return 0;
++ }
++ closedir(sysfs);
++
++ if (!acadstate) acadstate=(ACADstate *)malloc(sizeof(ACADstate));
++ /* this code doesn't make much sense.. why look at the whole directory?!
++ while ((propety = readdir(sysfs)))
++ {
++ name = propety->d_name;
++ if (!strncmp(".", name, 1) || !strncmp("..", name, 2)) continue;
++
++ if (strcmp(name,"online") == 0)
++ {
++ acadstate->state = ( read_sysfs_int("/sys/class/power_supply/AC/online") == 1 ) ;
++ }
++ }
++ */
++ sprintf(onlinefilepath, "%s/online", sysfsacdir);
++ /* if onlinefilepath doesn't exist read_sysfs_int() will return 0
++ so acadstate->state will be 0, that should be ok */
++ acadstate->state = ( read_sysfs_int(onlinefilepath) == 1 );
++
++ return acadstate->state;
++}
++
+ int read_acad_state(void)
+ {
+ #ifdef __linux__
++ if (acpi_sysfs)
++ return read_acad_state_sysfs();
+ FILE *acpi;
+ char *ptr;
+ char stat;
+@@ -354,20 +498,83 @@
+ #endif
+ }
+
++int read_acpi_info_sysfs(int battery)
++{
++ DIR *sysfs;
++ struct dirent *propety;
++ char *name;
++
++ sysfs = opendir(batteries[battery]);
++ if (sysfs == 0)
++ {
++ #ifdef DEBUG
++ printf("DBG:Can't open %s!\n", batteries[battery]);
++ #endif
++ return 0;
++ }
++ /* malloc.. might explain the random battery level values on 2.6.24
++ systems (energe_full is called charge_full so the value isn't initialised
++ and some random data from the heap is displayed..)
++ if (!acpiinfo) acpiinfo=(ACPIinfo *)malloc(sizeof(ACPIinfo));
++ */
++ if (!acpiinfo) acpiinfo=(ACPIinfo *)calloc(1, sizeof(ACPIinfo));
++
++ while ((propety = readdir(sysfs)))
++ {
++ name = propety->d_name;
++ if (!strncmp(".", name, 1) || !strncmp("..", name, 2)) continue;
++ /* at least on my system this is called charge_full */
++ if ((strcmp(name,"energy_full") == 0) || (strcmp(name,"charge_full") == 0))
++ {
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ acpiinfo->last_full_capacity = read_sysfs_int(buf);
++ }
++ if ((strcmp(name,"energy_full_design") == 0) || (strcmp(name,"charge_full_design") == 0))
++ {
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ acpiinfo->design_capacity = read_sysfs_int(buf);
++ }
++ if (strcmp(name,"technology") == 0)
++ {
++ char *tmp;
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ tmp = read_sysfs_string(buf);
++ if (tmp != NULL)
++ {
++ if (strcmp(tmp,"Li-ion") == 0)
++ acpiinfo->battery_technology = 1;
++ else
++ acpiinfo->battery_technology = 0;
++ }
++ }
++ if (strcmp(name,"present") == 0)
++ {
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ acpiinfo->present = read_sysfs_int(buf);
++ }
++ }
++ closedir(sysfs);
++ return acpiinfo->present;
++}
++
+ int read_acpi_info(int battery)
+ {
+ #ifdef __linux__
+- FILE *acpi;
+- char *ptr;
+- char stat;
+- int temp;
+-
+ if (battery > MAXBATT) {
+ #ifdef DEBUG
+ printf("DBG: error, battery > MAXBATT (%d)\n",MAXBATT);
+ #endif
+ return 0;
+ }
++
++ if (acpi_sysfs)
++ return read_acpi_info_sysfs(battery);
++
++ FILE *acpi;
++ char *ptr;
++ char stat;
++ int temp;
++
+ if (!(acpi = fopen (battinfo[battery], "r"))) {
+ #ifdef DEBUG
+ printf("DBG:cannot open %s for read!\n",battinfo[battery]);
+@@ -514,9 +721,80 @@
+
+ }
+
++int read_acpi_state_sysfs(int battery)
++{
++ DIR *sysfs;
++ struct dirent *propety;
++ char *name;
++
++ sysfs = opendir(batteries[battery]);
++ if (sysfs == 0)
++ {
++ #ifdef DEBUG
++ printf("DBG:Can't open %s!\n", batteries[battery]);
++ #endif
++ return 0;
++ }
++
++ /* again it might be better to use calloc
++ if (!acpistate) acpistate=(ACPIstate *)malloc(sizeof(ACPIstate));
++ */
++ if (!acpistate) acpistate=(ACPIstate *)calloc(1, sizeof(ACPIstate));
++
++ while ((propety = readdir(sysfs)))
++ {
++ name = propety->d_name;
++ if (!strncmp(".", name, 1) || !strncmp("..", name, 2)) continue;
++
++ if (strcmp(name,"status") == 0)
++ {
++ char *tmp;
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ tmp = read_sysfs_string(buf);
++ if ( tmp != NULL )
++ {
++ if (strcmp(tmp,"Charging") == 0)
++ acpistate->state = CHARGING;
++ else if (strcmp(tmp,"Discharging") == 0)
++ acpistate->state = DISCHARGING;
++ else if (strcmp(tmp,"Full") == 0)
++ acpistate->state = POWER;
++ else
++ acpistate->state = UNKNOW;
++ }
++ }
++ /* on my system this is called charge_now */
++ if ((strcmp(name,"energy_now") == 0) || (strcmp(name,"charge_now") == 0))
++ {
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ acpistate->rcapacity = read_sysfs_int(buf);
++ acpistate->percentage = (((float) acpistate->rcapacity)/acpiinfo->last_full_capacity) * 100;
++ }
++ if (strcmp(name,"current_now") == 0)
++ {
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ acpistate->prate = read_sysfs_int(buf);
++ if ( acpistate->prate < 0 )
++ acpistate->prate = 0;
++ if ( acpistate->prate > 0 )
++ acpistate->rtime = (((float) acpistate->rcapacity) / acpistate->prate) * 60;
++ }
++ if (strcmp(name,"voltage_now") == 0)
++ {
++ sprintf(buf,"%s/%s",batteries[battery], name);
++ acpistate->pvoltage = read_sysfs_int(buf);
++ }
++ }
++ closedir(sysfs);
++ return acpiinfo->present;
++}
++
+ int read_acpi_state(int battery)
+ {
+ #ifdef __linux__
++ if (acpi_sysfs)
++ return read_acpi_state_sysfs(battery);
++
+ FILE *acpi;
+ char *ptr;
+ char stat;
+diff -ru xfce4-battery-plugin-0.5.0.orig/panel-plugin/libacpi.h xfce4-battery-plugin-0.5.0-fixed/panel-plugin/libacpi.h
+--- xfce4-battery-plugin-0.5.0.orig/panel-plugin/libacpi.h 2007-01-17 18:56:51.000000000 +0100
++++ xfce4-battery-plugin-0.5.0-fixed/panel-plugin/libacpi.h 2008-04-05 22:13:55.522679792 +0200
+@@ -80,6 +80,8 @@
+ int batt_count;
+ /* temp buffer */
+ char buf[512];
++char buf2[512];
++int acpi_sysfs;
+ #else
+ extern int batt_count;
+ extern ACPIstate *acpistate;
diff --git a/xfce-extra/xfce4-battery/xfce4-battery-0.5.0-r3.ebuild b/xfce-extra/xfce4-battery/xfce4-battery-0.5.0-r3.ebuild
new file mode 100644
index 000000000000..b8d8675095cb
--- /dev/null
+++ b/xfce-extra/xfce4-battery/xfce4-battery-0.5.0-r3.ebuild
@@ -0,0 +1,33 @@
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/xfce-extra/xfce4-battery/xfce4-battery-0.5.0-r3.ebuild,v 1.1 2008/08/21 21:35:51 angelos Exp $
+
+inherit autotools eutils xfce44
+
+xfce44
+
+DESCRIPTION="Battery status panel plugin"
+KEYWORDS="~amd64 ~arm ~ppc ~ppc64 ~x86 ~x86-fbsd"
+IUSE="debug"
+
+DEPEND="dev-util/pkgconfig
+ dev-util/intltool
+ dev-util/xfce4-dev-tools"
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+ epatch "${FILESDIR}"/${P}-freebsd.patch \
+ "${FILESDIR}"/${P}-libacpi.patch \
+ "${FILESDIR}"/${P}-2.6.21.patch \
+ "${FILESDIR}"/${P}-2.6.24-headers.patch \
+ "${FILESDIR}"/${P}-sysfs.patch
+
+ sed -i -e "/^AC_INIT/s/battery_version()/battery_version/" configure.in
+ intltoolize --force --copy --automake || die "intltoolize failed."
+ AT_M4DIR=/usr/share/xfce4/dev-tools/m4macros eautoreconf
+}
+
+DOCS="AUTHORS ChangeLog NEWS README"
+
+xfce44_goodies_panel_plugin