]> git.sur5r.net Git - i3/i3status/commitdiff
introduce percentages for all values, document them
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 31 Aug 2012 12:16:58 +0000 (14:16 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 31 Aug 2012 12:16:58 +0000 (14:16 +0200)
i3status.conf
man/i3status.man
src/print_disk_info.c

index 99640d0f054be388f51db3f230ec4690ad61ecf0..5233041540c9a3fb1b93e29b6a3a03da6e8172a6 100644 (file)
@@ -45,5 +45,5 @@ load {
 }
 
 disk "/" {
-        format = "%free"
+        format = "%free (or: %percentage_used used, %percentage_used_of_avail used of avail, %percentage_free free, %percentage_avail avail)"
 }
index 5938acbd0b42e06bdd9d830716cad2bdba288419..35cdb73ae6d8e4562f223be4080c567d37c46711 100644 (file)
@@ -156,10 +156,15 @@ best available public IPv6 address on your computer).
 
 Gets used, free, available and total amount of bytes on the given mounted filesystem.
 
+These values can also be expressed in percentages with the percentage_used,
+percentage_free, percentage_avail and percentage_used_of_avail formats.
+
 *Example order*: +disk /mnt/usbstick+
 
 *Example format*: +%free (%avail)/ %total+
 
+*Example format*: +%percentage_used used, %percentage_free free, %percentage_avail avail+
+
 === Run-watch
 
 Expands the given path to a pidfile and checks if the process ID found inside
index a3124a1fe7544861bb131804d06118f296d54f38..b577d233ad56926e46418e0098ebc8c1f69a8be5 100644 (file)
@@ -86,10 +86,25 @@ 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");
+
+                if (BEGINS_WITH(walk+1, "percentage_free")) {
+                        outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)buf.f_bfree / (double)buf.f_blocks);
+                        walk += strlen("percentage_free");
+                }
+
+                if (BEGINS_WITH(walk+1, "percentage_used_of_avail")) {
+                        outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)(buf.f_blocks - buf.f_bavail) / (double)buf.f_blocks);
+                        walk += strlen("percentage_used_of_avail");
+                }
+
+                if (BEGINS_WITH(walk+1, "percentage_used")) {
+                        outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)(buf.f_blocks - buf.f_bfree) / (double)buf.f_blocks);
+                        walk += strlen("percentage_used");
+                }
+
+                if (BEGINS_WITH(walk+1, "percentage_avail")) {
+                        outwalk += sprintf(outwalk, "%.01f%%", 100.0 * (double)buf.f_bavail / (double)buf.f_blocks);
+                        walk += strlen("percentage_avail");
                 }
         }