From c85295202b0fc1b6dc63c02ebac59bdf8a41cad8 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 22 Nov 2009 18:02:56 +0100 Subject: [PATCH] convert cpubar to callbacks.barval --- src/common.c | 5 +++++ src/common.h | 2 ++ src/conky.c | 4 +--- src/core.c | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common.c b/src/common.c index edf1ac23..a6dbfaf5 100644 --- a/src/common.c +++ b/src/common.c @@ -472,3 +472,8 @@ void print_loadgraph(struct text_object *obj, char *p, int p_max_size) new_graph(obj, p, p_max_size, info.loadavg[0]); } #endif /* X11 */ + +uint8_t cpu_barval(struct text_object *obj) +{ + return (uint8_t)(info.cpu_usage[obj->data.i] * 255.0); +} diff --git a/src/common.h b/src/common.h index 22646b4b..a9df8641 100644 --- a/src/common.h +++ b/src/common.h @@ -75,4 +75,6 @@ void scan_loadgraph_arg(struct text_object *, const char *); void print_loadgraph(struct text_object *, char *, int); #endif /* X11 */ +uint8_t cpu_barval(struct text_object *); + #endif /* _COMMON_H */ diff --git a/src/conky.c b/src/conky.c index cbda6da8..740fe8d7 100644 --- a/src/conky.c +++ b/src/conky.c @@ -886,10 +886,8 @@ void generate_text_internal(char *p, int p_max_size, percent_print(p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 100.0)); } - OBJ(cpugauge) + OBJ(cpugauge) { new_gauge(obj, p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 255.0)); - OBJ(cpubar) { - new_bar(obj, p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 255.0)); } #ifdef X11 OBJ(cpugraph) { diff --git a/src/core.c b/src/core.c index 6630863d..d3d11366 100644 --- a/src/core.c +++ b/src/core.c @@ -393,6 +393,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ(cpubar, &update_cpu_usage) SCAN_CPU(arg, obj->data.i); scan_bar(obj, arg); + obj->callbacks.barval = &cpu_barval; DBGP2("Adding $cpubar for CPU %d", obj->data.i); #ifdef X11 END OBJ(cpugraph, &update_cpu_usage)