mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
convert cpu to callbacks.percentage
This commit is contained in:
parent
79f5726832
commit
07f82f5cb6
10
src/common.c
10
src/common.c
@ -472,6 +472,16 @@ uint8_t loadgraphval(struct text_object *obj)
|
|||||||
}
|
}
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
|
||||||
|
uint8_t cpu_percentage(struct text_object *obj)
|
||||||
|
{
|
||||||
|
if (obj->data.i > info.cpu_count) {
|
||||||
|
NORM_ERR("obj->data.i %i info.cpu_count %i",
|
||||||
|
obj->data.i, info.cpu_count);
|
||||||
|
CRIT_ERR(NULL, NULL, "attempting to use more CPUs than you have!");
|
||||||
|
}
|
||||||
|
return round_to_int(info.cpu_usage[obj->data.i] * 100.0);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t cpu_barval(struct text_object *obj)
|
uint8_t cpu_barval(struct text_object *obj)
|
||||||
{
|
{
|
||||||
return round_to_int(info.cpu_usage[obj->data.i] * 255.0);
|
return round_to_int(info.cpu_usage[obj->data.i] * 255.0);
|
||||||
|
@ -75,6 +75,7 @@ void scan_loadgraph_arg(struct text_object *, const char *);
|
|||||||
uint8_t loadgraphval(struct text_object *);
|
uint8_t loadgraphval(struct text_object *);
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
|
||||||
|
uint8_t cpu_percentage(struct text_object *);
|
||||||
uint8_t cpu_barval(struct text_object *);
|
uint8_t cpu_barval(struct text_object *);
|
||||||
uint8_t mem_barval(struct text_object *);
|
uint8_t mem_barval(struct text_object *);
|
||||||
uint8_t swap_barval(struct text_object *);
|
uint8_t swap_barval(struct text_object *);
|
||||||
|
@ -874,15 +874,6 @@ void generate_text_internal(char *p, int p_max_size,
|
|||||||
OBJ(cmdline_to_pid) {
|
OBJ(cmdline_to_pid) {
|
||||||
print_cmdline_to_pid(obj, p, p_max_size);
|
print_cmdline_to_pid(obj, p, p_max_size);
|
||||||
}
|
}
|
||||||
OBJ(cpu) {
|
|
||||||
if (obj->data.i > info.cpu_count) {
|
|
||||||
NORM_ERR("obj->data.i %i info.cpu_count %i",
|
|
||||||
obj->data.i, info.cpu_count);
|
|
||||||
CRIT_ERR(NULL, NULL, "attempting to use more CPUs than you have!");
|
|
||||||
}
|
|
||||||
percent_print(p, p_max_size,
|
|
||||||
round_to_int(cur->cpu_usage[obj->data.i] * 100.0));
|
|
||||||
}
|
|
||||||
#ifdef X11
|
#ifdef X11
|
||||||
OBJ(font) {
|
OBJ(font) {
|
||||||
new_font(p, obj->data.s);
|
new_font(p, obj->data.s);
|
||||||
|
@ -386,6 +386,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
|||||||
}
|
}
|
||||||
END OBJ(cpu, &update_cpu_usage)
|
END OBJ(cpu, &update_cpu_usage)
|
||||||
SCAN_CPU(arg, obj->data.i);
|
SCAN_CPU(arg, obj->data.i);
|
||||||
|
obj->callbacks.percentage = &cpu_percentage;
|
||||||
DBGP2("Adding $cpu for CPU %d", obj->data.i);
|
DBGP2("Adding $cpu for CPU %d", obj->data.i);
|
||||||
END OBJ(cpugauge, &update_cpu_usage)
|
END OBJ(cpugauge, &update_cpu_usage)
|
||||||
SCAN_CPU(arg, obj->data.i);
|
SCAN_CPU(arg, obj->data.i);
|
||||||
|
Loading…
Reference in New Issue
Block a user