all repos — slstatus @ 6624985cf4537440cb6403e319d16ce83bee43f2

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

fixed disk percent
Aaron Marcher info@nulltime.net
Fri, 11 Mar 2016 13:11:15 +0100
commit

6624985cf4537440cb6403e319d16ce83bee43f2

parent

faae8292fb5b752c885e1e6970592dacb020c754

1 files changed, 9 insertions(+), 3 deletions(-)

jump to
M slstatus.cslstatus.c

@@ -210,14 +210,20 @@ /* disk usage percentage */

char * get_diskusage() { + int perc = 0; struct statvfs fs; - float perc = 0; + + /* try to open mountpoint */ if (statvfs(mountpath, &fs) < 0) { fprintf(stderr, "Could not get filesystem info.\n"); return smprintf("n/a"); } - perc = 1.0f - ((float)fs.f_bavail/(float)fs.f_blocks); - return smprintf("%2f%%", perc); + + /* calculate percent */ + perc = 100 * (1.0f - ((float)fs.f_bavail / (float)fs.f_blocks)); + + /* return perc */ + return smprintf("%d%%", perc); } /* ram percentage */