1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 04:06:03 +00:00

convert swapperc to callbacks.percentage

This commit is contained in:
Phil Sutter 2009-11-25 01:34:54 +01:00
parent feba298efa
commit 0631b2ab2e
4 changed files with 9 additions and 7 deletions

View File

@ -501,6 +501,13 @@ uint8_t mem_barval(struct text_object *obj)
return round_to_int(info.memmax ? (info.mem * 255 / info.memmax) : 0);
}
uint8_t swap_percentage(struct text_object *obj)
{
(void)obj;
return (info.swapmax ? round_to_int(info.swap * 100 / info.swapmax) : 0);
}
uint8_t swap_barval(struct text_object *obj)
{
(void)obj;

View File

@ -79,6 +79,7 @@ uint8_t cpu_percentage(struct text_object *);
uint8_t cpu_barval(struct text_object *);
uint8_t mem_percentage(struct text_object *);
uint8_t mem_barval(struct text_object *);
uint8_t swap_percentage(struct text_object *);
uint8_t swap_barval(struct text_object *);
#endif /* _COMMON_H */

View File

@ -1329,13 +1329,6 @@ void generate_text_internal(char *p, int p_max_size,
OBJ(swapmax) {
human_readable(cur->swapmax * 1024, p, 255);
}
OBJ(swapperc) {
if (cur->swapmax == 0) {
strncpy(p, "No swap", p_max_size);
} else {
percent_print(p, p_max_size, cur->swap * 100 / cur->swapmax);
}
}
OBJ(sysname) {
snprintf(p, p_max_size, "%s", cur->uname_s.sysname);
}

View File

@ -972,6 +972,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
END OBJ(swapfree, &update_meminfo)
END OBJ(swapmax, &update_meminfo)
END OBJ(swapperc, &update_meminfo)
obj->callbacks.percentage = &swap_percentage;
END OBJ(swapbar, &update_meminfo)
scan_bar(obj, arg);
obj->callbacks.barval = &swap_barval;