diff --git a/src/conky.c b/src/conky.c index fa46ba59..8b62d21a 100644 --- a/src/conky.c +++ b/src/conky.c @@ -969,17 +969,6 @@ void generate_text_internal(char *p, int p_max_size, OBJ(eval) { evaluate(obj->data.s, p, p_max_size); } - OBJ(fs_bar) { - print_fs_bar(obj, 0, p, p_max_size); - } - OBJ(fs_free_perc) { - print_fs_perc(obj, 1, p, p_max_size); - } - OBJ(fs_bar_free) { - print_fs_bar(obj, 1, p, p_max_size); - } - OBJ(fs_used_perc) { - print_fs_perc(obj, 0, p, p_max_size); } #ifdef HDDTEMP OBJ(hddtemp) { diff --git a/src/core.c b/src/core.c index 09c8609c..a0b7da29 100644 --- a/src/core.c +++ b/src/core.c @@ -576,15 +576,19 @@ struct text_object *construct_text_object(const char *s, const char *arg, long scan_pre_exec_arg(obj, arg); END OBJ(fs_bar, &update_fs_stats) init_fs_bar(obj, arg); + obj->callbacks.print = &print_fs_bar; END OBJ(fs_bar_free, &update_fs_stats) init_fs_bar(obj, arg); + obj->callbacks.print = &print_fs_bar_free; END OBJ(fs_free, &update_fs_stats) init_fs(obj, arg); obj->callbacks.print = &print_fs_free; END OBJ(fs_used_perc, &update_fs_stats) init_fs(obj, arg); + obj->callbacks.print = &print_fs_used_perc; END OBJ(fs_free_perc, &update_fs_stats) init_fs(obj, arg); + obj->callbacks.print = &print_fs_free_perc; END OBJ(fs_size, &update_fs_stats) init_fs(obj, arg); obj->callbacks.print = &print_fs_size; diff --git a/src/fs.c b/src/fs.c index ad9140d9..c7b42d0d 100644 --- a/src/fs.c +++ b/src/fs.c @@ -211,7 +211,7 @@ void init_fs_bar(struct text_object *obj, const char *arg) obj->data.opaque = prepare_fs_stat(arg); } -void print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_size) +static void do_print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_size) { double val = 1.0; struct fs_stat *fs = obj->data.opaque; @@ -228,12 +228,22 @@ void print_fs_bar(struct text_object *obj, int be_free_bar, char *p, int p_max_s new_bar(obj, p, p_max_size, (int)(255 * val)); } +void print_fs_bar(struct text_object *obj, char *p, int p_max_size) +{ + do_print_fs_bar(obj, 0, p, p_max_size); +} + +void print_fs_bar_free(struct text_object *obj, char *p, int p_max_size) +{ + do_print_fs_bar(obj, 1, p, p_max_size); +} + void init_fs(struct text_object *obj, const char *arg) { obj->data.opaque = prepare_fs_stat(arg ? arg : "/"); } -void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size) +static void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size) { struct fs_stat *fs = obj->data.opaque; int val = 100; @@ -250,6 +260,16 @@ void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size percent_print(p, p_max_size, val); } +void print_fs_free_perc(struct text_object *obj, char *p, int p_max_size) +{ + print_fs_perc(obj, 1, p, p_max_size); +} + +void print_fs_used_perc(struct text_object *obj, char *p, int p_max_size) +{ + print_fs_perc(obj, 0, p, p_max_size); +} + #define HUMAN_PRINT_FS_GENERATOR(name, expr) \ void print_fs_##name(struct text_object *obj, char *p, int p_max_size) \ { \ diff --git a/src/fs.h b/src/fs.h index 0c93c8ec..8c1b0f8d 100644 --- a/src/fs.h +++ b/src/fs.h @@ -19,10 +19,12 @@ struct fs_stat { struct text_object; void init_fs_bar(struct text_object *, const char *); -void print_fs_bar(struct text_object *, int, char *, int); +void print_fs_bar(struct text_object *, char *, int); +void print_fs_bar_free(struct text_object *, char *, int); void init_fs(struct text_object *, const char *); -void print_fs_perc(struct text_object *, int, char *, int); +void print_fs_free_perc(struct text_object *, char *, int); +void print_fs_used_perc(struct text_object *, char *, int); void print_fs_free(struct text_object *, char *, int); void print_fs_size(struct text_object *, char *, int); void print_fs_used(struct text_object *, char *, int);