summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2012-08-31 14:16:58 +0200
committerMichael Stapelberg <michael@stapelberg.de>2012-08-31 14:16:58 +0200
commitd6b8a4efc1c07f3bbf5f01f524986ecb496711a0 (patch)
tree01a89fb7592b94fa7baebd02209d4e84a36f4e42
parent50ad0334f648d74c0093bf95270e5f60859888ae (diff)
introduce percentages for all values, document them
-rw-r--r--i3status.conf2
-rw-r--r--man/i3status.man5
-rw-r--r--src/print_disk_info.c23
3 files changed, 25 insertions, 5 deletions
diff --git a/i3status.conf b/i3status.conf
index 99640d0..5233041 100644
--- a/i3status.conf
+++ b/i3status.conf
@@ -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)"
}
diff --git a/man/i3status.man b/man/i3status.man
index 5938acb..35cdb73 100644
--- a/man/i3status.man
+++ b/man/i3status.man
@@ -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
diff --git a/src/print_disk_info.c b/src/print_disk_info.c
index a3124a1..b577d23 100644
--- a/src/print_disk_info.c
+++ b/src/print_disk_info.c
@@ -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");
}
}