powertop: update to 2.0.

This commit is contained in:
Juan RP 2012-05-18 00:39:35 +02:00
parent 4313a669aa
commit 00389f2066
3 changed files with 15 additions and 144 deletions

View File

@ -1,138 +0,0 @@
--- powertop.c.orig 2010-07-20 01:08:21.000000000 +0200
+++ 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;

View File

@ -1,2 +1,9 @@
libncursesw.so.6
libc.so.6
libpci.so.3
libnl-genl-3.so.200
libnl-3.so.200
libpthread.so.0
libstdc++.so.6
libm.so.6
libgcc_s.so.1

View File

@ -1,13 +1,13 @@
# Template file for 'powertop'
pkgname=powertop
version=1.13
homepage="http://www.lesswatts.org/projects/powertop/"
distfiles="http://www.lesswatts.org/projects/powertop/download/$pkgname-$version.tar.gz"
build_style=gnu-makefile
version=2.0
homepage="https://01.org/powertop/"
distfiles="https://01.org/powertop/sites/default/files/downloads/$pkgname-$version.tar.bz2"
build_style=gnu-configure
short_desc="Linux tool to find out what is using power on a laptop"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2"
checksum=2bc866089496877dd26d2d316ad5763ab8ecb5e28aefba44bc5d355dcdc58d98
checksum=7af51d320856b3446bcc314c9414385f3b05b9360f650883b0210cd3b12c5c1c
long_desc="
PowerTOP is a Linux tool that finds the software component(s) that make your
laptop use more power than necessary while it is idle. As of Linux kernel
@ -20,5 +20,7 @@ long_desc="
the kernel into one convenient screen so that you can see how well your system
is doing, and which components are the biggest problem."
Add_dependency build zlib-devel
Add_dependency build pkg-config
Add_dependency build ncurses-devel
Add_dependency build pciutils-devel
Add_dependency build libnl3-devel