mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 11:05:18 +00:00
convert fs_*_perc to callbacks.percentage
This commit is contained in:
parent
61c4efb305
commit
36a202091e
@ -600,10 +600,10 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
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;
|
||||
obj->callbacks.percentage = &fs_used_percentage;
|
||||
END OBJ(fs_free_perc, &update_fs_stats)
|
||||
init_fs(obj, arg);
|
||||
obj->callbacks.print = &print_fs_free_perc;
|
||||
obj->callbacks.percentage = &fs_free_percentage;
|
||||
END OBJ(fs_size, &update_fs_stats)
|
||||
init_fs(obj, arg);
|
||||
obj->callbacks.print = &print_fs_size;
|
||||
|
14
src/fs.c
14
src/fs.c
@ -243,13 +243,13 @@ void init_fs(struct text_object *obj, const char *arg)
|
||||
obj->data.opaque = prepare_fs_stat(arg ? arg : "/");
|
||||
}
|
||||
|
||||
static void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_max_size)
|
||||
static uint8_t fs_percentage(struct text_object *obj, int be_free)
|
||||
{
|
||||
struct fs_stat *fs = obj->data.opaque;
|
||||
int val = 100;
|
||||
|
||||
if (!fs)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
if (fs->size)
|
||||
val = fs->avail * 100 / fs->size;
|
||||
@ -257,17 +257,17 @@ static void print_fs_perc(struct text_object *obj, int be_free, char *p, int p_m
|
||||
if (!be_free)
|
||||
val = 100 - val;
|
||||
|
||||
percent_print(p, p_max_size, val);
|
||||
return val;
|
||||
}
|
||||
|
||||
void print_fs_free_perc(struct text_object *obj, char *p, int p_max_size)
|
||||
uint8_t fs_free_percentage(struct text_object *obj)
|
||||
{
|
||||
print_fs_perc(obj, 1, p, p_max_size);
|
||||
return fs_percentage(obj, 1);
|
||||
}
|
||||
|
||||
void print_fs_used_perc(struct text_object *obj, char *p, int p_max_size)
|
||||
uint8_t fs_used_percentage(struct text_object *obj)
|
||||
{
|
||||
print_fs_perc(obj, 0, p, p_max_size);
|
||||
return fs_percentage(obj, 0);
|
||||
}
|
||||
|
||||
#define HUMAN_PRINT_FS_GENERATOR(name, expr) \
|
||||
|
4
src/fs.h
4
src/fs.h
@ -23,8 +23,8 @@ uint8_t fs_barval(struct text_object *);
|
||||
uint8_t fs_free_barval(struct text_object *);
|
||||
|
||||
void init_fs(struct text_object *, const char *);
|
||||
void print_fs_free_perc(struct text_object *, char *, int);
|
||||
void print_fs_used_perc(struct text_object *, char *, int);
|
||||
uint8_t fs_free_percentage(struct text_object *);
|
||||
uint8_t fs_used_percentage(struct text_object *);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user