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

convert mem and swap objects to callbacks.print

This commit is contained in:
Phil Sutter 2009-11-26 00:09:38 +01:00
parent ef60b7eb8a
commit 177da5ffbb
4 changed files with 30 additions and 23 deletions

View File

@ -487,6 +487,21 @@ uint8_t cpu_barval(struct text_object *obj)
return round_to_int(info.cpu_usage[obj->data.i] * 255.0);
}
#define PRINT_HR_GENERATOR(name) \
void print_##name(struct text_object *obj, char *p, int p_max_size) \
{ \
(void)obj; \
human_readable(info.name * 1024, p, p_max_size); \
}
PRINT_HR_GENERATOR(mem)
PRINT_HR_GENERATOR(memeasyfree)
PRINT_HR_GENERATOR(memfree)
PRINT_HR_GENERATOR(memmax)
PRINT_HR_GENERATOR(swap)
PRINT_HR_GENERATOR(swapfree)
PRINT_HR_GENERATOR(swapmax)
uint8_t mem_percentage(struct text_object *obj)
{
(void)obj;

View File

@ -73,6 +73,14 @@ uint8_t loadgraphval(struct text_object *);
uint8_t cpu_percentage(struct text_object *);
uint8_t cpu_barval(struct text_object *);
void print_mem(struct text_object *, char *, int);
void print_memeasyfree(struct text_object *, char *, int);
void print_memfree(struct text_object *, char *, int);
void print_memmax(struct text_object *, char *, int);
void print_swap(struct text_object *, char *, int);
void print_swapfree(struct text_object *, char *, int);
void print_swapmax(struct text_object *, char *, int);
uint8_t mem_percentage(struct text_object *);
uint8_t mem_barval(struct text_object *);
uint8_t swap_percentage(struct text_object *);

View File

@ -963,20 +963,6 @@ void generate_text_internal(char *p, int p_max_size,
snprintf(p, p_max_size, "%s", cur->uname_s.machine);
}
/* memory stuff */
OBJ(mem) {
human_readable(cur->mem * 1024, p, 255);
}
OBJ(memeasyfree) {
human_readable(cur->memeasyfree * 1024, p, 255);
}
OBJ(memfree) {
human_readable(cur->memfree * 1024, p, 255);
}
OBJ(memmax) {
human_readable(cur->memmax * 1024, p, 255);
}
OBJ(format_time) {
char buf[max_user_text];
@ -1282,15 +1268,6 @@ void generate_text_internal(char *p, int p_max_size,
OBJ(text) {
snprintf(p, p_max_size, "%s", obj->data.s);
}
OBJ(swap) {
human_readable(cur->swap * 1024, p, 255);
}
OBJ(swapfree) {
human_readable(cur->swapfree * 1024, p, 255);
}
OBJ(swapmax) {
human_readable(cur->swapmax * 1024, p, 255);
}
OBJ(sysname) {
snprintf(p, p_max_size, "%s", cur->uname_s.sysname);
}

View File

@ -765,9 +765,13 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
obj->callbacks.print = &print_mboxscan;
obj->callbacks.free = &free_mboxscan;
END OBJ(mem, &update_meminfo)
obj->callbacks.print = &print_mem;
END OBJ(memeasyfree, &update_meminfo)
obj->callbacks.print = &print_memeasyfree;
END OBJ(memfree, &update_meminfo)
obj->callbacks.print = &print_memfree;
END OBJ(memmax, &update_meminfo)
obj->callbacks.print = &print_memmax;
END OBJ(memperc, &update_meminfo)
obj->callbacks.percentage = &mem_percentage;
END OBJ(memgauge, &update_meminfo)
@ -974,8 +978,11 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
obj->callbacks.print = &new_stippled_hr;
#endif /* X11 */
END OBJ(swap, &update_meminfo)
obj->callbacks.print = &print_swap;
END OBJ(swapfree, &update_meminfo)
obj->callbacks.print = &print_swapfree;
END OBJ(swapmax, &update_meminfo)
obj->callbacks.print = &print_swapmax;
END OBJ(swapperc, &update_meminfo)
obj->callbacks.percentage = &swap_percentage;
END OBJ(swapbar, &update_meminfo)