mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
update machinery: complete transition
* Drop all need_mask alterations (no idea why there were here at all, but surely not sane since they are missing in the non-linux functions). * Drop the update delay for update_meminfo(), as parsing /proc should not lead to abnormal overhead. * Check for x_initialised from inside update_x11info(), so we can call it unconditionally.
This commit is contained in:
parent
d7c7f06aca
commit
e044093735
23
src/common.c
23
src/common.c
@ -423,15 +423,10 @@ int no_buffers;
|
||||
void update_stuff(void)
|
||||
{
|
||||
int i;
|
||||
static double last_meminfo_update;
|
||||
struct update_cb *uc;
|
||||
|
||||
info.mask = 0;
|
||||
|
||||
if (no_buffers) {
|
||||
need_mask |= 1 << INFO_BUFFERS;
|
||||
}
|
||||
|
||||
/* clear speeds and up status in case device was removed and doesn't get
|
||||
* updated */
|
||||
|
||||
@ -451,21 +446,11 @@ void update_stuff(void)
|
||||
for (uc = update_cb_head.next; uc; uc = uc->next)
|
||||
(*uc->func)();
|
||||
|
||||
if ((NEED(INFO_MEM) || NEED(INFO_BUFFERS) || NEED(INFO_TOP))
|
||||
&& current_update_time - last_meminfo_update > 6.9) {
|
||||
update_meminfo();
|
||||
if (no_buffers) {
|
||||
info.mem -= info.bufmem;
|
||||
info.memeasyfree += info.bufmem;
|
||||
}
|
||||
last_meminfo_update = current_update_time;
|
||||
/* XXX: move the following into the update_meminfo() functions? */
|
||||
if (no_buffers) {
|
||||
info.mem -= info.bufmem;
|
||||
info.memeasyfree += info.bufmem;
|
||||
}
|
||||
|
||||
#ifdef X11
|
||||
if (NEED(INFO_X11) && x_initialised == YES) {
|
||||
update_x11info();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Ohkie to return negative values for temperatures */
|
||||
|
42
src/conky.h
42
src/conky.h
@ -207,64 +207,22 @@ extern struct conftree *currentconffile;
|
||||
char **get_templates(void);
|
||||
|
||||
enum {
|
||||
INFO_CPU = 0,
|
||||
INFO_MAIL = 1,
|
||||
INFO_MEM = 2,
|
||||
INFO_NET = 3,
|
||||
INFO_PROCS = 4,
|
||||
INFO_RUN_PROCS = 5,
|
||||
INFO_UPTIME = 6,
|
||||
INFO_BUFFERS = 7,
|
||||
INFO_FS = 8,
|
||||
INFO_SYSFS = 9,
|
||||
INFO_MIXER = 10,
|
||||
INFO_LOADAVG = 11,
|
||||
INFO_UNAME = 12,
|
||||
INFO_FREQ = 13,
|
||||
#ifdef MPD
|
||||
INFO_MPD = 14,
|
||||
#endif
|
||||
INFO_TOP = 15,
|
||||
INFO_WIFI = 16,
|
||||
INFO_DISKIO = 17,
|
||||
INFO_I8K = 18,
|
||||
#ifdef TCP_PORT_MONITOR
|
||||
INFO_TCP_PORT_MONITOR = 19,
|
||||
#endif
|
||||
#ifdef AUDACIOUS
|
||||
INFO_AUDACIOUS = 20,
|
||||
#endif
|
||||
#ifdef BMPX
|
||||
INFO_BMPX = 21,
|
||||
#endif
|
||||
#ifdef XMMS2
|
||||
INFO_XMMS2 = 22,
|
||||
#endif
|
||||
INFO_ENTROPY = 23,
|
||||
#ifdef IBM
|
||||
INFO_SMAPI = 25,
|
||||
#endif
|
||||
INFO_USERS = 26,
|
||||
INFO_GW = 27,
|
||||
#ifdef NVIDIA
|
||||
INFO_NVIDIA = 28,
|
||||
#endif
|
||||
#ifdef X11
|
||||
INFO_X11 = 29,
|
||||
#endif
|
||||
INFO_DNS = 30,
|
||||
#ifdef MOC
|
||||
INFO_MOC = 31,
|
||||
#endif
|
||||
#ifdef APCUPSD
|
||||
INFO_APCUPSD = 32,
|
||||
#endif
|
||||
#ifdef WEATHER
|
||||
INFO_WEATHER = 33,
|
||||
#endif
|
||||
#ifdef HDDTEMP
|
||||
INFO_HDDTEMP = 34,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* get_battery_stuff() item selector
|
||||
|
43
src/core.c
43
src/core.c
@ -543,8 +543,8 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ(obsd_vendor, 0)
|
||||
END OBJ(obsd_product, 0)
|
||||
#endif /* __OpenBSD__ */
|
||||
END OBJ(buffers, INFO_BUFFERS)
|
||||
END OBJ(cached, INFO_BUFFERS)
|
||||
END OBJ(buffers, CALLBACK(&update_meminfo))
|
||||
END OBJ(cached, CALLBACK(&update_meminfo))
|
||||
#define SCAN_CPU(__arg, __var) { \
|
||||
int __offset = 0; \
|
||||
if (__arg && sscanf(__arg, " cpu%u %n", &__var, &__offset) > 0) \
|
||||
@ -1032,6 +1032,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
* avoid having almost-same code four times, we have this special
|
||||
* handler. */
|
||||
if (strncmp(s, "top", 3) == EQUAL) {
|
||||
add_update_callback(&update_meminfo);
|
||||
if (!parse_top_args(s, arg, obj)) {
|
||||
return NULL;
|
||||
}
|
||||
@ -1368,21 +1369,21 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
/* if '1' (in mboxscan.c) then there was SIGUSR1, hmm */
|
||||
obj->data.mboxscan.output[0] = 1;
|
||||
strncpy(obj->data.mboxscan.args, arg, text_buffer_size);
|
||||
END OBJ(mem, INFO_MEM)
|
||||
END OBJ(memeasyfree, INFO_MEM)
|
||||
END OBJ(memfree, INFO_MEM)
|
||||
END OBJ(memmax, INFO_MEM)
|
||||
END OBJ(memperc, INFO_MEM)
|
||||
END OBJ(mem, CALLBACK(&update_meminfo))
|
||||
END OBJ(memeasyfree, CALLBACK(&update_meminfo))
|
||||
END OBJ(memfree, CALLBACK(&update_meminfo))
|
||||
END OBJ(memmax, CALLBACK(&update_meminfo))
|
||||
END OBJ(memperc, CALLBACK(&update_meminfo))
|
||||
#ifdef X11
|
||||
END OBJ(memgauge, INFO_MEM)
|
||||
END OBJ(memgauge, CALLBACK(&update_meminfo))
|
||||
SIZE_DEFAULTS(gauge);
|
||||
scan_gauge(arg, &obj->data.pair.a, &obj->data.pair.b);
|
||||
#endif /* X11*/
|
||||
END OBJ(membar, INFO_MEM)
|
||||
END OBJ(membar, CALLBACK(&update_meminfo))
|
||||
SIZE_DEFAULTS(bar);
|
||||
scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
|
||||
#ifdef X11
|
||||
END OBJ(memgraph, INFO_MEM)
|
||||
END OBJ(memgraph, CALLBACK(&update_meminfo))
|
||||
char *buf = 0;
|
||||
SIZE_DEFAULTS(graph);
|
||||
buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
|
||||
@ -1413,11 +1414,11 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ_IF(if_mixer_mute, INFO_MIXER)
|
||||
obj->data.ifblock.i = mixer_init(arg);
|
||||
#ifdef X11
|
||||
END OBJ(monitor, INFO_X11)
|
||||
END OBJ(monitor_number, INFO_X11)
|
||||
END OBJ(desktop, INFO_X11)
|
||||
END OBJ(desktop_number, INFO_X11)
|
||||
END OBJ(desktop_name, INFO_X11)
|
||||
END OBJ(monitor, CALLBACK(&update_x11info))
|
||||
END OBJ(monitor_number, CALLBACK(&update_x11info))
|
||||
END OBJ(desktop, CALLBACK(&update_x11info))
|
||||
END OBJ(desktop_number, CALLBACK(&update_x11info))
|
||||
END OBJ(desktop_name, CALLBACK(&update_x11info))
|
||||
#endif
|
||||
END OBJ(nodename, 0)
|
||||
END OBJ(processes, CALLBACK(&update_total_processes))
|
||||
@ -1445,11 +1446,11 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
obj->data.pair.a = a;
|
||||
obj->data.pair.b = b;
|
||||
#endif /* X11 */
|
||||
END OBJ(swap, INFO_MEM)
|
||||
END OBJ(swapfree, INFO_MEM)
|
||||
END OBJ(swapmax, INFO_MEM)
|
||||
END OBJ(swapperc, INFO_MEM)
|
||||
END OBJ(swapbar, INFO_MEM)
|
||||
END OBJ(swap, CALLBACK(&update_meminfo))
|
||||
END OBJ(swapfree, CALLBACK(&update_meminfo))
|
||||
END OBJ(swapmax, CALLBACK(&update_meminfo))
|
||||
END OBJ(swapperc, CALLBACK(&update_meminfo))
|
||||
END OBJ(swapbar, CALLBACK(&update_meminfo))
|
||||
SIZE_DEFAULTS(bar);
|
||||
scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
|
||||
END OBJ(sysname, 0)
|
||||
@ -1564,7 +1565,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
free(buf);
|
||||
#endif
|
||||
END OBJ(uptime_short, CALLBACK(&update_uptime))
|
||||
END OBJ(uptime, INFO_UPTIME)
|
||||
END OBJ(uptime, CALLBACK(&update_uptime))
|
||||
END OBJ(user_names, CALLBACK(&update_users))
|
||||
END OBJ(user_times, CALLBACK(&update_users))
|
||||
END OBJ(user_terms, CALLBACK(&update_users))
|
||||
|
11
src/linux.c
11
src/linux.c
@ -116,7 +116,6 @@ void update_uptime(void)
|
||||
fscanf(fp, "%lf", &info.uptime);
|
||||
fclose(fp);
|
||||
}
|
||||
info.mask |= (1 << INFO_UPTIME);
|
||||
}
|
||||
|
||||
int check_mount(char *s)
|
||||
@ -185,8 +184,6 @@ void update_meminfo(void)
|
||||
|
||||
info.bufmem = info.cached + info.buffers;
|
||||
|
||||
info.mask |= (1 << INFO_MEM) | (1 << INFO_BUFFERS);
|
||||
|
||||
fclose(meminfo_fp);
|
||||
}
|
||||
|
||||
@ -509,8 +506,6 @@ void update_net_stats(void)
|
||||
first = 0;
|
||||
|
||||
fclose(net_dev_fp);
|
||||
|
||||
info.mask |= (1 << INFO_NET);
|
||||
}
|
||||
|
||||
int result;
|
||||
@ -536,7 +531,6 @@ void update_total_processes(void)
|
||||
fscanf(fp, "%*f %*f %*f %*d/%hu", &info.procs);
|
||||
fclose(fp);
|
||||
}
|
||||
info.mask |= (1 << INFO_PROCS);
|
||||
}
|
||||
|
||||
#define CPU_SAMPLE_COUNT 15
|
||||
@ -657,7 +651,6 @@ inline static void update_stat(void)
|
||||
|
||||
if (strncmp(buf, "procs_running ", 14) == 0) {
|
||||
sscanf(buf, "%*s %hu", &info.run_procs);
|
||||
info.mask |= (1 << INFO_RUN_PROCS);
|
||||
} else if (strncmp(buf, "cpu", 3) == 0) {
|
||||
double delta;
|
||||
if (isdigit(buf[3])) {
|
||||
@ -678,7 +671,6 @@ inline static void update_stat(void)
|
||||
|
||||
cpu[idx].cpu_active_total = cpu[idx].cpu_total -
|
||||
(cpu[idx].cpu_idle + cpu[idx].cpu_iowait);
|
||||
info.mask |= (1 << INFO_CPU);
|
||||
|
||||
delta = current_update_time - last_update_time;
|
||||
|
||||
@ -755,7 +747,6 @@ void update_load_average(void)
|
||||
&info.loadavg[2]);
|
||||
fclose(fp);
|
||||
}
|
||||
info.mask |= (1 << INFO_LOADAVG);
|
||||
}
|
||||
|
||||
#define PROC_I8K "/proc/i8k"
|
||||
@ -2146,8 +2137,6 @@ void update_entropy(void)
|
||||
|
||||
fclose(fp1);
|
||||
fclose(fp2);
|
||||
|
||||
info.mask |= (1 << INFO_ENTROPY);
|
||||
}
|
||||
|
||||
const char *get_disk_protect_queue(const char *disk)
|
||||
|
@ -733,8 +733,6 @@ int parse_top_args(const char *s, const char *arg, struct text_object *obj)
|
||||
obj->data.top.s = strndup(arg, text_buffer_size);
|
||||
}
|
||||
|
||||
need_mask |= (1 << INFO_TOP);
|
||||
|
||||
if (s[3] == 0) {
|
||||
obj->type = OBJ_top;
|
||||
top_cpu = 1;
|
||||
|
@ -705,6 +705,8 @@ void get_x11_desktop_info(Display *current_display, Atom atom)
|
||||
void update_x11info(void)
|
||||
{
|
||||
struct information *current_info = &info;
|
||||
if (!x_initialised == YES)
|
||||
return;
|
||||
current_info->x11.monitor.number = XScreenCount(display);
|
||||
current_info->x11.monitor.current = XDefaultScreen(display);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user