diff options
author | root <root@rshg054.dnsready.net> | 2012-03-06 00:01:33 +0000 |
---|---|---|
committer | root <root@rshg054.dnsready.net> | 2012-03-06 00:01:33 +0000 |
commit | b8afacf1f28ac27321feb9b92bd50dd8961b7736 (patch) | |
tree | de441882aca38091a1e438e1d8da8a9af3bd023a /community/powertop | |
parent | 11711de1942a141f28faef695c4c78c8357fbf23 (diff) |
Tue Mar 6 00:01:33 UTC 2012
Diffstat (limited to 'community/powertop')
-rw-r--r-- | community/powertop/PKGBUILD | 14 | ||||
-rw-r--r-- | community/powertop/powertop-1.13-with-3.0.6.patch | 142 |
2 files changed, 152 insertions, 4 deletions
diff --git a/community/powertop/PKGBUILD b/community/powertop/PKGBUILD index 83f906f85..2f981488c 100644 --- a/community/powertop/PKGBUILD +++ b/community/powertop/PKGBUILD @@ -1,21 +1,27 @@ -# $Id: PKGBUILD 24103 2010-08-19 22:45:29Z heftig $ +# $Id: PKGBUILD 67110 2012-03-04 12:47:55Z stativ $ # Maintainer: Jaroslav Lichtblau <dragonlord@aur.archlinux.org> # Contributor: Alexander Fehr <pizzapunk gmail com> # Contributor: Xilon <xilonmu@gmail.com> pkgname=powertop pkgver=1.13 -pkgrel=2 +pkgrel=3 pkgdesc="Tool that finds the software that makes your laptop use more power than necessary" arch=('i686' 'x86_64') url="http://www.lesswatts.org/projects/powertop/" license=('GPL2') depends=('ncurses') -source=(http://www.lesswatts.org/projects/powertop/download/$pkgname-$pkgver.tar.gz) -md5sums=('78aa17c8f55178004223bf236654298e') +source=(http://www.lesswatts.org/projects/powertop/download/$pkgname-$pkgver.tar.gz \ + powertop-1.13-with-3.0.6.patch) +md5sums=('78aa17c8f55178004223bf236654298e' + '2b4c9d75fb0f5c96bcd549bcbbeb9c9d') build() { cd "$srcdir/powertop-$pkgver" + + # fix the reported batery usage on recent kernels + patch -Np1 < "$srcdir/powertop-1.13-with-3.0.6.patch" || true + make } diff --git a/community/powertop/powertop-1.13-with-3.0.6.patch b/community/powertop/powertop-1.13-with-3.0.6.patch new file mode 100644 index 000000000..fc61913a8 --- /dev/null +++ b/community/powertop/powertop-1.13-with-3.0.6.patch @@ -0,0 +1,142 @@ +Common subdirectories: powertop-1.13/kernel-patches and powertop-patched/kernel-patches +Common subdirectories: powertop-1.13/po and powertop-patched/po +diff -u powertop-1.13/powertop.c powertop-patched/powertop.c +--- powertop-1.13/powertop.c 2010-07-20 01:08:21.000000000 +0200 ++++ powertop-patched/powertop.c 2011-10-20 14:34:41.163951192 +0200 +@@ -547,95 +547,6 @@ + qsort (lines, linehead, sizeof (struct line), line_compare); + } + +- +- +-int print_battery_proc_acpi(void) +-{ +- DIR *dir; +- struct dirent *dirent; +- FILE *file; +- double rate = 0; +- double cap = 0; +- +- char filename[256]; +- +- dir = opendir("/proc/acpi/battery"); +- if (!dir) +- return 0; +- +- while ((dirent = readdir(dir))) { +- int dontcount = 0; +- double voltage = 0.0; +- double amperes_drawn = 0.0; +- double watts_drawn = 0.0; +- double amperes_left = 0.0; +- double watts_left = 0.0; +- char line[1024]; +- +- if (strlen(dirent->d_name) < 3) +- continue; +- +- sprintf(filename, "/proc/acpi/battery/%s/state", dirent->d_name); +- file = fopen(filename, "r"); +- if (!file) +- continue; +- memset(line, 0, 1024); +- while (fgets(line, 1024, file) != NULL) { +- char *c; +- if (strstr(line, "present:") && strstr(line, "no")) +- break; +- +- if (strstr(line, "charging state:") +- && !strstr(line, "discharging")) +- dontcount = 1; +- c = strchr(line, ':'); +- if (!c) +- continue; +- c++; +- +- if (strstr(line, "present voltage")) +- voltage = strtoull(c, NULL, 10) / 1000.0; +- +- if (strstr(line, "remaining capacity") && strstr(c, "mW")) +- watts_left = strtoull(c, NULL, 10) / 1000.0; +- +- if (strstr(line, "remaining capacity") && strstr(c, "mAh")) +- amperes_left = strtoull(c, NULL, 10) / 1000.0; +- +- if (strstr(line, "present rate") && strstr(c, "mW")) +- watts_drawn = strtoull(c, NULL, 10) / 1000.0 ; +- +- if (strstr(line, "present rate") && strstr(c, "mA")) +- amperes_drawn = strtoull(c, NULL, 10) / 1000.0; +- +- } +- fclose(file); +- +- if (!dontcount) { +- rate += watts_drawn + voltage * amperes_drawn; +- } +- cap += watts_left + voltage * amperes_left; +- +- +- } +- closedir(dir); +- if (prev_bat_cap - cap < 0.001 && rate < 0.001) +- last_bat_time = 0; +- if (!last_bat_time) { +- last_bat_time = prev_bat_time = time(NULL); +- last_bat_cap = prev_bat_cap = cap; +- } +- if (time(NULL) - last_bat_time >= 400) { +- prev_bat_cap = last_bat_cap; +- prev_bat_time = last_bat_time; +- last_bat_time = time(NULL); +- last_bat_cap = cap; +- } +- +- show_acpi_power_line(rate, cap, prev_bat_cap - cap, time(NULL) - prev_bat_time); +- return 1; +-} +- + int print_battery_proc_pmu(void) + { + char line[80]; +@@ -719,9 +630,6 @@ + + char filename[256]; + +- if (print_battery_proc_acpi()) +- return; +- + if (print_battery_proc_pmu()) + return; + +@@ -733,7 +641,6 @@ + while ((dirent = readdir(dir))) { + int dontcount = 0; + double voltage = 0.0; +- double amperes_drawn = 0.0; + double watts_drawn = 0.0; + double watts_left = 0.0; + char line[1024]; +@@ -790,8 +697,12 @@ + watts_left *= strtoull(line, NULL, 10) / 1000000.0; + fclose(file); + +- sprintf(filename, "/sys/class/power_supply/%s/current_now", dirent->d_name); ++ sprintf(filename, "/sys/class/power_supply/%s/power_now", dirent->d_name); + file = fopen(filename, "r"); ++ if (!file) { ++ sprintf(filename, "/sys/class/power_supply/%s/current_now", dirent->d_name); ++ file = fopen(filename, "r"); ++ } + if (!file) + continue; + memset(line, 0, 1024); +@@ -801,7 +712,7 @@ + fclose(file); + + if (!dontcount) { +- rate += watts_drawn + voltage * amperes_drawn; ++ rate += watts_drawn; + } + cap += watts_left; + |