From b6e691e8ac1d09df7a01c25583b785025a6212a6 Mon Sep 17 00:00:00 2001 From: Or Cohen Date: Thu, 9 Apr 2009 15:28:45 -0600 Subject: [PATCH] Minor fix for fs_used_perc, fs_free and fs_free_perc --- ChangeLog | 5 +++++ src/conky.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4ed8211a..de8aef0b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-04-09 + * Fix broken xmms2 compilation (thanks fusetak) + * Minor fix for fs_used_perc, fs_free and fs_free_perc (thanks + lightpriest) + 2009-03-28 * Applied FreeBSD patches (thanks Nikos) diff --git a/src/conky.c b/src/conky.c index 49d88a89..e5a9f7fa 100644 --- a/src/conky.c +++ b/src/conky.c @@ -3719,15 +3719,19 @@ static void generate_text_internal(char *p, int p_max_size, } OBJ(fs_free) { if (obj->data.fs != NULL) { - human_readable(obj->data.fs->avail, p, 255); + human_readable( (obj->data.fs->free ? obj->data.fs->free : + obj->data.fs->avail), p, 255); } } OBJ(fs_free_perc) { if (obj->data.fs != NULL) { int val = 0; - if (obj->data.fs->size) - val = obj->data.fs->avail * 100 / obj->data.fs->size; + if (obj->data.fs->size) { + val = (obj->data.fs->free ? obj->data.fs->free : + obj->data.fs->avail) * 100 / + obj->data.fs->size; + } percent_print(p, p_max_size, val); } @@ -3762,8 +3766,11 @@ static void generate_text_internal(char *p, int p_max_size, if (obj->data.fs != NULL) { int val = 0; - if (obj->data.fs->size) - val = obj->data.fs->avail * 100 / obj->data.fs->size; + if (obj->data.fs->size) { + val = (obj->data.fs->free ? obj->data.fs->free : + obj->data.fs->avail) * 100 / + obj->data.fs->size; + } percent_print(p, p_max_size, 100 - val); }