all repos — slstatus @ 11e9491fc03d0d72bcf1d984ddd546abd06474a0

my build of slstatus (tools.suckless.org/slstatus/)

small changes (var names)
Aaron Marcher info@nulltime.net
Thu, 10 Mar 2016 08:37:20 +0100
commit

11e9491fc03d0d72bcf1d984ddd546abd06474a0

parent

2d1b92115c75a0da9b18be84f8f26bcf01b9f35f

1 files changed, 15 insertions(+), 16 deletions(-)

jump to
M slstatus.cslstatus.c

@@ -64,7 +64,7 @@ /* battery percentage */

char * get_battery() { - int battery_now, battery_full, battery_perc; + int now, full, perc; FILE *fp; /* open battery now file */

@@ -74,7 +74,7 @@ exit(1);

} /* read value */ - fscanf(fp, "%i", &battery_now); + fscanf(fp, "%i", &now); /* close battery now file */ fclose(fp);

@@ -86,16 +86,16 @@ exit(1);

} /* read value */ - fscanf(fp, "%i", &battery_full); + fscanf(fp, "%i", &full); /* close battery full file */ fclose(fp); /* calculate percent */ - battery_perc = battery_now / (battery_full / 100); + perc = now / (full / 100); - /* return batt_perc as string */ - return smprintf("%d%%", battery_perc); + /* return perc as string */ + return smprintf("%d%%", perc); } /* cpu temperature */

@@ -125,7 +125,7 @@ /* cpu percentage */

char * get_cpu_usage() { - int cpu_perc; + int perc; long double a[4], b[4]; FILE *fp;

@@ -157,10 +157,10 @@ /* close stat file */

fclose(fp); /* calculate avg in this second */ - cpu_perc = 100 * ((b[0]+b[1]+b[2]) - (a[0]+a[1]+a[2])) / ((b[0]+b[1]+b[2]+b[3]) - (a[0]+a[1]+a[2]+a[3])); + perc = 100 * ((b[0]+b[1]+b[2]) - (a[0]+a[1]+a[2])) / ((b[0]+b[1]+b[2]+b[3]) - (a[0]+a[1]+a[2]+a[3])); - /* return cpu_perc as string */ - return smprintf("%d%%", cpu_perc); + /* return perc as string */ + return smprintf("%d%%", perc); } /* date and time */

@@ -179,14 +179,14 @@ exit(1);

} /* return time */ - return buf; + return smprintf("%s", buf); } /* ram percentage */ char * get_ram_usage() { - int ram_perc; + int perc; long total, free, buffers, cached; FILE *fp;

@@ -206,10 +206,10 @@ /* close meminfo file */

fclose(fp); /* calculate percentage */ - ram_perc = 100 * ((total - free) - (buffers + cached)) / total; + perc = 100 * ((total - free) - (buffers + cached)) / total; - /* return ram_perc as string */ - return smprintf("%d%%",ram_perc); + /* return perc as string */ + return smprintf("%d%%", perc); } /* alsa volume percentage */

@@ -266,7 +266,6 @@ char needle[sizeof wificard + 1];

FILE *fp; /* generate the path name */ - memset(path, 0, sizeof path); strcat(path, path_start); strcat(path, wificard);