mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-12 11:04:10 +00:00
convert mem{gauge,graph,bar} to callbacks
This commit is contained in:
parent
b2b9155514
commit
d2f3ae7e15
@ -475,5 +475,12 @@ void print_loadgraph(struct text_object *obj, char *p, int p_max_size)
|
||||
|
||||
uint8_t cpu_barval(struct text_object *obj)
|
||||
{
|
||||
return (uint8_t)(info.cpu_usage[obj->data.i] * 255.0);
|
||||
return round_to_int(info.cpu_usage[obj->data.i] * 255.0);
|
||||
}
|
||||
|
||||
uint8_t mem_barval(struct text_object *obj)
|
||||
{
|
||||
(void)obj;
|
||||
|
||||
return round_to_int(info.memmax ? (info.mem * 255 / info.memmax) : 0);
|
||||
}
|
||||
|
@ -76,5 +76,6 @@ void print_loadgraph(struct text_object *, char *, int);
|
||||
#endif /* X11 */
|
||||
|
||||
uint8_t cpu_barval(struct text_object *);
|
||||
uint8_t mem_barval(struct text_object *);
|
||||
|
||||
#endif /* _COMMON_H */
|
||||
|
11
src/conky.c
11
src/conky.c
@ -997,17 +997,6 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
if (cur->memmax)
|
||||
percent_print(p, p_max_size, cur->mem * 100 / cur->memmax);
|
||||
}
|
||||
OBJ(memgauge){
|
||||
new_gauge(obj, p, p_max_size, cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
|
||||
}
|
||||
OBJ(membar) {
|
||||
new_bar(obj, p, p_max_size, cur->memmax ? (cur->mem * 255) / (cur->memmax) : 0);
|
||||
}
|
||||
#ifdef X11
|
||||
OBJ(memgraph) {
|
||||
new_graph(obj, p, p_max_size, cur->memmax ? (cur->mem * 100.0) / (cur->memmax) : 0.0);
|
||||
}
|
||||
#endif /* X11 */
|
||||
#ifdef X11
|
||||
#define NOT_IN_X "Not running in X"
|
||||
OBJ(monitor) {
|
||||
|
@ -768,14 +768,17 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ(memperc, &update_meminfo)
|
||||
END OBJ(memgauge, &update_meminfo)
|
||||
scan_gauge(obj, arg);
|
||||
obj->callbacks.gaugeval = &mem_barval;
|
||||
END OBJ(membar, &update_meminfo)
|
||||
scan_bar(obj, arg);
|
||||
obj->callbacks.barval = &mem_barval;
|
||||
#ifdef X11
|
||||
END OBJ(memgraph, &update_meminfo)
|
||||
char *buf = 0;
|
||||
buf = scan_graph(obj, arg, 100);
|
||||
|
||||
if (buf) free(buf);
|
||||
obj->callbacks.graphval = &mem_barval;
|
||||
#endif /* X11*/
|
||||
END OBJ(mixer, 0)
|
||||
parse_mixer_arg(obj, arg);
|
||||
|
Loading…
Reference in New Issue
Block a user