summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOctavian Cerna <octavian.cerna@gmail.com>2014-12-30 22:08:10 +0200
committerOctavian Cerna <octavian.cerna@gmail.com>2015-08-03 00:41:08 +0300
commite6e2927270adf1883185855490cd4927f2bf2713 (patch)
treeaf76fcc69fefd599596781b443ac471b238e06dd
parent0d4dafcd35e5b7ceb42fd98891f5aa9838ab84a5 (diff)
Add disk usage.
-rw-r--r--statusbar.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/statusbar.c b/statusbar.c
index 42406a0..08c0c86 100644
--- a/statusbar.c
+++ b/statusbar.c
@@ -4,6 +4,7 @@
#include <string.h>
#include <stdarg.h>
#include <time.h>
+#include <sys/statvfs.h>
#include <X11/Xlib.h>
#define INTERVAL 2
@@ -151,6 +152,19 @@ static void status_mem(void)
}
+static void status_disk(void)
+{
+ struct statvfs st;
+ double used;
+
+ if (statvfs("/", &st) == -1)
+ return;
+
+ used = (st.f_blocks - st.f_bfree) * 100.0 / st.f_blocks;
+ add_status("Disk %s%.f%s%%", used >= 90 ? HOT : COOL, used, NORMAL);
+}
+
+
static void status_net(void)
{
FILE *fp;
@@ -258,6 +272,7 @@ int main()
status_cpu();
status_mem();
+ status_disk();
status_net();
status_bat();
status_wifi();