mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-11 10:38:12 +00:00
text_object: use field i instead of cpu_index
This commit is contained in:
parent
3a365bcd33
commit
ac99833646
26
src/conky.c
26
src/conky.c
@ -811,18 +811,18 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
OBJ(freq) {
|
||||
if (obj->a) {
|
||||
obj->a = get_freq(p, p_max_size, "%.0f", 1,
|
||||
obj->data.cpu_index);
|
||||
obj->data.i);
|
||||
}
|
||||
}
|
||||
OBJ(freq_g) {
|
||||
if (obj->a) {
|
||||
#ifndef __OpenBSD__
|
||||
obj->a = get_freq(p, p_max_size, "%'.2f", 1000,
|
||||
obj->data.cpu_index);
|
||||
obj->data.i);
|
||||
#else
|
||||
/* OpenBSD has no such flag (SUSv2) */
|
||||
obj->a = get_freq(p, p_max_size, "%.2f", 1000,
|
||||
obj->data.cpu_index);
|
||||
obj->data.i);
|
||||
#endif /* __OpenBSD */
|
||||
}
|
||||
}
|
||||
@ -830,13 +830,13 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
OBJ(voltage_mv) {
|
||||
if (obj->a) {
|
||||
obj->a = get_voltage(p, p_max_size, "%.0f", 1,
|
||||
obj->data.cpu_index);
|
||||
obj->data.i);
|
||||
}
|
||||
}
|
||||
OBJ(voltage_v) {
|
||||
if (obj->a) {
|
||||
obj->a = get_voltage(p, p_max_size, "%'.3f", 1000,
|
||||
obj->data.cpu_index);
|
||||
obj->data.i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -915,28 +915,28 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
human_readable(cur->cached * 1024, p, 255);
|
||||
}
|
||||
OBJ(cpu) {
|
||||
if (obj->data.cpu_index > info.cpu_count) {
|
||||
NORM_ERR("obj->data.cpu_index %i info.cpu_count %i",
|
||||
obj->data.cpu_index, info.cpu_count);
|
||||
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.cpu_index] * 100.0));
|
||||
round_to_int(cur->cpu_usage[obj->data.i] * 100.0));
|
||||
}
|
||||
#ifdef X11
|
||||
OBJ(cpugauge)
|
||||
new_gauge(p, obj->a, obj->b,
|
||||
round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
|
||||
round_to_int(cur->cpu_usage[obj->data.i] * 255.0));
|
||||
#endif /* X11 */
|
||||
OBJ(cpubar) {
|
||||
#ifdef X11
|
||||
if(output_methods & TO_X) {
|
||||
new_bar(p, obj->a, obj->b,
|
||||
round_to_int(cur->cpu_usage[obj->data.cpu_index] * 255.0));
|
||||
round_to_int(cur->cpu_usage[obj->data.i] * 255.0));
|
||||
}else{
|
||||
#endif /* X11 */
|
||||
if(!obj->a) obj->a = DEFAULT_BAR_WIDTH_NO_X;
|
||||
new_bar_in_shell(p, p_max_size, round_to_int(cur->cpu_usage[obj->data.cpu_index] * 100), obj->a);
|
||||
new_bar_in_shell(p, p_max_size, round_to_int(cur->cpu_usage[obj->data.i] * 100), obj->a);
|
||||
#ifdef X11
|
||||
}
|
||||
#endif /* X11 */
|
||||
@ -944,7 +944,7 @@ void generate_text_internal(char *p, int p_max_size,
|
||||
#ifdef X11
|
||||
OBJ(cpugraph) {
|
||||
new_graph(p, obj->a, obj->b, obj->c, obj->d,
|
||||
round_to_int(cur->cpu_usage[obj->data.cpu_index] * 100),
|
||||
round_to_int(cur->cpu_usage[obj->data.i] * 100),
|
||||
100, 1, obj->char_a, obj->char_b);
|
||||
}
|
||||
OBJ(loadgraph) {
|
||||
|
@ -234,7 +234,7 @@ struct information {
|
||||
|
||||
float *cpu_usage;
|
||||
/* struct cpu_stat cpu_summed; what the hell is this? */
|
||||
unsigned int cpu_count;
|
||||
int cpu_count;
|
||||
int cpu_avg_samples;
|
||||
|
||||
int net_avg_samples;
|
||||
|
42
src/core.c
42
src/core.c
@ -163,23 +163,23 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
#endif /* !__OpenBSD__ */
|
||||
get_cpu_count();
|
||||
if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
|
||||
|| (unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.cpu_index = 1;
|
||||
|| atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
|
||||
"Displaying the clock for CPU 1."); */
|
||||
} else {
|
||||
obj->data.cpu_index = atoi(&arg[0]);
|
||||
obj->data.i = atoi(&arg[0]);
|
||||
}
|
||||
obj->a = 1;
|
||||
END OBJ(freq_g, 0)
|
||||
get_cpu_count();
|
||||
if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
|
||||
|| (unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.cpu_index = 1;
|
||||
|| atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
|
||||
"CPUs! Displaying the clock for CPU 1."); */
|
||||
} else {
|
||||
obj->data.cpu_index = atoi(&arg[0]);
|
||||
obj->data.i = atoi(&arg[0]);
|
||||
}
|
||||
obj->a = 1;
|
||||
END OBJ_ARG(read_tcp, 0, "read_tcp: Needs \"(host) port\" as argument(s)")
|
||||
@ -188,23 +188,23 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ(voltage_mv, 0)
|
||||
get_cpu_count();
|
||||
if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
|
||||
|| (unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.cpu_index = 1;
|
||||
|| atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many "
|
||||
"CPUs! Displaying voltage for CPU 1."); */
|
||||
} else {
|
||||
obj->data.cpu_index = atoi(&arg[0]);
|
||||
obj->data.i = atoi(&arg[0]);
|
||||
}
|
||||
obj->a = 1;
|
||||
END OBJ(voltage_v, 0)
|
||||
get_cpu_count();
|
||||
if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
|
||||
|| (unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.cpu_index = 1;
|
||||
|| atoi(&arg[0]) > info.cpu_count) {
|
||||
obj->data.i = 1;
|
||||
/* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many "
|
||||
"CPUs! Displaying voltage for CPU 1."); */
|
||||
} else {
|
||||
obj->data.cpu_index = atoi(&arg[0]);
|
||||
obj->data.i = atoi(&arg[0]);
|
||||
}
|
||||
obj->a = 1;
|
||||
|
||||
@ -337,34 +337,34 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ(cached, &update_meminfo)
|
||||
#define SCAN_CPU(__arg, __var) { \
|
||||
int __offset = 0; \
|
||||
if (__arg && sscanf(__arg, " cpu%u %n", &__var, &__offset) > 0) \
|
||||
if (__arg && sscanf(__arg, " cpu%d %n", &__var, &__offset) > 0) \
|
||||
__arg += __offset; \
|
||||
else \
|
||||
__var = 0; \
|
||||
}
|
||||
END OBJ(cpu, &update_cpu_usage)
|
||||
SCAN_CPU(arg, obj->data.cpu_index);
|
||||
DBGP2("Adding $cpu for CPU %d", obj->data.cpu_index);
|
||||
SCAN_CPU(arg, obj->data.i);
|
||||
DBGP2("Adding $cpu for CPU %d", obj->data.i);
|
||||
#ifdef X11
|
||||
END OBJ(cpugauge, &update_cpu_usage)
|
||||
SIZE_DEFAULTS(gauge);
|
||||
SCAN_CPU(arg, obj->data.cpu_index);
|
||||
SCAN_CPU(arg, obj->data.i);
|
||||
scan_gauge(arg, &obj->a, &obj->b);
|
||||
DBGP2("Adding $cpugauge for CPU %d", obj->data.cpu_index);
|
||||
DBGP2("Adding $cpugauge for CPU %d", obj->data.i);
|
||||
#endif /* X11 */
|
||||
END OBJ(cpubar, &update_cpu_usage)
|
||||
SIZE_DEFAULTS(bar);
|
||||
SCAN_CPU(arg, obj->data.cpu_index);
|
||||
SCAN_CPU(arg, obj->data.i);
|
||||
scan_bar(arg, &obj->a, &obj->b);
|
||||
DBGP2("Adding $cpubar for CPU %d", obj->data.cpu_index);
|
||||
DBGP2("Adding $cpubar for CPU %d", obj->data.i);
|
||||
#ifdef X11
|
||||
END OBJ(cpugraph, &update_cpu_usage)
|
||||
char *buf = 0;
|
||||
SIZE_DEFAULTS(graph);
|
||||
SCAN_CPU(arg, obj->data.cpu_index);
|
||||
SCAN_CPU(arg, obj->data.i);
|
||||
buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
|
||||
&obj->e, &obj->char_a, &obj->char_b);
|
||||
DBGP2("Adding $cpugraph for CPU %d", obj->data.cpu_index);
|
||||
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
|
||||
if (buf) free(buf);
|
||||
END OBJ(loadgraph, &update_load_average)
|
||||
char *buf = 0;
|
||||
|
@ -443,7 +443,6 @@ struct text_object {
|
||||
int i; /* some integer */
|
||||
long l; /* some other integer */
|
||||
unsigned char loadavg[3];
|
||||
unsigned int cpu_index;
|
||||
struct mail_s *mail;
|
||||
|
||||
struct {
|
||||
|
Loading…
Reference in New Issue
Block a user