diff --git a/src/common.c b/src/common.c index 8d5695d8..34cc42f3 100644 --- a/src/common.c +++ b/src/common.c @@ -487,6 +487,13 @@ uint8_t cpu_barval(struct text_object *obj) return round_to_int(info.cpu_usage[obj->data.i] * 255.0); } +uint8_t mem_percentage(struct text_object *obj) +{ + (void)obj; + + return (info.memmax ? round_to_int(info.mem * 100 / info.memmax) : 0); +} + uint8_t mem_barval(struct text_object *obj) { (void)obj; diff --git a/src/common.h b/src/common.h index c92d79c8..79d910b2 100644 --- a/src/common.h +++ b/src/common.h @@ -77,6 +77,7 @@ uint8_t loadgraphval(struct text_object *); 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_barval(struct text_object *); diff --git a/src/conky.c b/src/conky.c index 7c835def..486dbab5 100644 --- a/src/conky.c +++ b/src/conky.c @@ -976,10 +976,6 @@ void generate_text_internal(char *p, int p_max_size, OBJ(memmax) { human_readable(cur->memmax * 1024, p, 255); } - OBJ(memperc) { - if (cur->memmax) - percent_print(p, p_max_size, cur->mem * 100 / cur->memmax); - } #ifdef X11 #define NOT_IN_X "Not running in X" OBJ(monitor) { diff --git a/src/core.c b/src/core.c index 03a670df..48a46b6a 100644 --- a/src/core.c +++ b/src/core.c @@ -769,6 +769,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ(memfree, &update_meminfo) END OBJ(memmax, &update_meminfo) END OBJ(memperc, &update_meminfo) + obj->callbacks.percentage = &mem_percentage; END OBJ(memgauge, &update_meminfo) scan_gauge(obj, arg); obj->callbacks.gaugeval = &mem_barval;