]> git.sur5r.net Git - i3/i3status/commitdiff
adding percentage format string for disk info module
authorgereon <gereon.kremer@rwth-aachen.de>
Thu, 30 Aug 2012 17:32:33 +0000 (19:32 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 31 Aug 2012 12:07:46 +0000 (14:07 +0200)
explicit cast to double, changed format string to percentage

src/print_disk_info.c

index 8bc8b4116ebfdd4f2440e8c360b32e6254420a75..a3124a1fe7544861bb131804d06118f296d54f38 100644 (file)
@@ -86,6 +86,11 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
                         outwalk += print_bytes_human(outwalk, (uint64_t)buf.f_bsize * (uint64_t)buf.f_bavail);
                         walk += strlen("avail");
                 }
+                
+                if (BEGINS_WITH(walk+1, "percentage")) {
+                        outwalk += sprintf(outwalk, "%.01f%%", 100.0 - 100.0 * (double)buf.f_bavail / (double)buf.f_blocks);
+                        walk += strlen("percentage");
+                }
         }
 
         *outwalk = '\0';