1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

convert cpubar to callbacks.barval

This commit is contained in:
Phil Sutter 2009-11-22 18:02:56 +01:00
parent 06a4650f60
commit c85295202b
4 changed files with 9 additions and 3 deletions

View File

@ -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]); new_graph(obj, p, p_max_size, info.loadavg[0]);
} }
#endif /* X11 */ #endif /* X11 */
uint8_t cpu_barval(struct text_object *obj)
{
return (uint8_t)(info.cpu_usage[obj->data.i] * 255.0);
}

View File

@ -75,4 +75,6 @@ void scan_loadgraph_arg(struct text_object *, const char *);
void print_loadgraph(struct text_object *, char *, int); void print_loadgraph(struct text_object *, char *, int);
#endif /* X11 */ #endif /* X11 */
uint8_t cpu_barval(struct text_object *);
#endif /* _COMMON_H */ #endif /* _COMMON_H */

View File

@ -886,10 +886,8 @@ void generate_text_internal(char *p, int p_max_size,
percent_print(p, p_max_size, percent_print(p, p_max_size,
round_to_int(cur->cpu_usage[obj->data.i] * 100.0)); 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)); 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 #ifdef X11
OBJ(cpugraph) { OBJ(cpugraph) {

View File

@ -393,6 +393,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
END OBJ(cpubar, &update_cpu_usage) END OBJ(cpubar, &update_cpu_usage)
SCAN_CPU(arg, obj->data.i); SCAN_CPU(arg, obj->data.i);
scan_bar(obj, arg); scan_bar(obj, arg);
obj->callbacks.barval = &cpu_barval;
DBGP2("Adding $cpubar for CPU %d", obj->data.i); DBGP2("Adding $cpubar for CPU %d", obj->data.i);
#ifdef X11 #ifdef X11
END OBJ(cpugraph, &update_cpu_usage) END OBJ(cpugraph, &update_cpu_usage)