--- config.def.h | 6 +++--- slstatus.c | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 6370008..4807ce8 100644 --- a/config.def.h +++ b/config.def.h _AT_@ -16,8 +16,8 @@ static const char unknown_str[] = "n/a"; * battery_power battery power usage battery name * battery_state battery charging state battery name * cpu_perc cpu usage in percent NULL - * cpu_iowait cpu iowait in percent NULL - * cpu_freq cpu frequency in MHz NULL + * cpu_iowait cpu iowait in percent cpu count + * cpu_freq cpu frequency in MHz cpu count * datetime date and time format string * disk_free free disk space in GB mountpoint path * disk_perc disk usage in percent mountpoint path _AT_@ -51,7 +51,7 @@ static const char unknown_str[] = "n/a"; */ static const struct arg args[] = { /* function format argument */ - { cpu_perc, "[CPU %3s%%] ", NULL }, + { cpu_perc, "[CPU %3s%%] ", 4 }, { ram_perc, "[RAM %2s%%] ", NULL }, { datetime, "[ %s ]", "%F %T" }, }; diff --git a/slstatus.c b/slstatus.c index cddc79a..88bcba9 100644 --- a/slstatus.c +++ b/slstatus.c _AT_@ -40,8 +40,8 @@ static const char *battery_perc(const char *bat); static const char *battery_power(const char *bat); static const char *battery_state(const char *bat); static const char *cpu_freq(void); -static const char *cpu_perc(void); -static const char *cpu_iowait(void); +static const char *cpu_perc(long ncpu); +static const char *cpu_iowait(long ncpu); static const char *datetime(const char *fmt); static const char *disk_free(const char *mnt); static const char *disk_perc(const char *mnt); _AT_@ -177,7 +177,7 @@ cpu_freq(void) } static const char * -cpu_perc(void) +cpu_perc(long ncpu) { int perc; static long double a[7]; _AT_@ -197,11 +197,11 @@ cpu_perc(void) perc = 100 * ((b[0]+b[1]+b[2]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[5]+a[6])) / ((b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6])); - return bprintf("%d", perc); + return bprintf("%d", (ncpu?:1)*perc); } static const char * -cpu_iowait(void) +cpu_iowait(long ncpu) { int perc; static int valid; _AT_@ -221,7 +221,7 @@ cpu_iowait(void) perc = 100 * ((b[4]) - (a[4])) / ((b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6])); - return bprintf("%d", perc); + return bprintf("%d", (ncpu?:1)*perc); } static const char * -- 1.8.5.rc3Received on Mon Sep 11 2017 - 20:05:54 CEST
This archive was generated by hypermail 2.3.0 : Mon Sep 11 2017 - 20:12:58 CEST