mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 11:05:18 +00:00
Merge remote branch 'origin/master' into lua-config
This commit is contained in:
commit
109770ac31
16
src/core.cc
16
src/core.cc
@ -581,12 +581,16 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
|||||||
#endif /* BUILD_IMLIB2 */
|
#endif /* BUILD_IMLIB2 */
|
||||||
END OBJ(exec, 0)
|
END OBJ(exec, 0)
|
||||||
scan_exec_arg(obj, arg);
|
scan_exec_arg(obj, arg);
|
||||||
|
obj->parse = false;
|
||||||
|
obj->thread = false;
|
||||||
obj->callbacks.print = &print_exec;
|
obj->callbacks.print = &print_exec;
|
||||||
obj->callbacks.free = &free_exec;
|
obj->callbacks.free = &free_exec;
|
||||||
END OBJ(execp, 0)
|
END OBJ(execp, 0)
|
||||||
scan_exec_arg(obj, arg);
|
scan_exec_arg(obj, arg);
|
||||||
obj->verbatim_output = 1;
|
obj->verbatim_output = 1;
|
||||||
obj->callbacks.print = &print_execp;
|
obj->parse = true;
|
||||||
|
obj->thread = false;
|
||||||
|
obj->callbacks.print = &print_exec;
|
||||||
obj->callbacks.free = &free_exec;
|
obj->callbacks.free = &free_exec;
|
||||||
END OBJ(execbar, 0)
|
END OBJ(execbar, 0)
|
||||||
scan_exec_arg(obj, arg);
|
scan_exec_arg(obj, arg);
|
||||||
@ -618,22 +622,28 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
|||||||
obj->callbacks.free = &free_execi;
|
obj->callbacks.free = &free_execi;
|
||||||
END OBJ_ARG(execi, 0, "execi needs arguments")
|
END OBJ_ARG(execi, 0, "execi needs arguments")
|
||||||
scan_execi_arg(obj, arg);
|
scan_execi_arg(obj, arg);
|
||||||
|
obj->parse = false;
|
||||||
|
obj->thread = false;
|
||||||
obj->callbacks.print = &print_execi;
|
obj->callbacks.print = &print_execi;
|
||||||
obj->callbacks.free = &free_execi;
|
obj->callbacks.free = &free_execi;
|
||||||
END OBJ_ARG(execpi, 0, "execpi needs arguments")
|
END OBJ_ARG(execpi, 0, "execpi needs arguments")
|
||||||
scan_execi_arg(obj, arg);
|
scan_execi_arg(obj, arg);
|
||||||
obj->verbatim_output = 1;
|
obj->verbatim_output = 1;
|
||||||
obj->parse = true;
|
obj->parse = true;
|
||||||
|
obj->thread = false;
|
||||||
obj->callbacks.print = &print_execi;
|
obj->callbacks.print = &print_execi;
|
||||||
obj->callbacks.free = &free_execi;
|
obj->callbacks.free = &free_execi;
|
||||||
END OBJ_ARG(texeci, 0, "texeci needs arguments")
|
END OBJ_ARG(texeci, 0, "texeci needs arguments")
|
||||||
scan_execi_arg(obj, arg);
|
scan_execi_arg(obj, arg);
|
||||||
obj->callbacks.print = &print_texeci;
|
obj->parse = false;
|
||||||
|
obj->thread = true;
|
||||||
|
obj->callbacks.print = &print_execi;
|
||||||
obj->callbacks.free = &free_execi;
|
obj->callbacks.free = &free_execi;
|
||||||
END OBJ_ARG(texecpi, 0, "texecpi needs arguments")
|
END OBJ_ARG(texecpi, 0, "texecpi needs arguments")
|
||||||
scan_execi_arg(obj, arg);
|
scan_execi_arg(obj, arg);
|
||||||
obj->parse = true;
|
obj->parse = true;
|
||||||
obj->callbacks.print = &print_texeci;
|
obj->thread = true;
|
||||||
|
obj->callbacks.print = &print_execi;
|
||||||
obj->callbacks.free = &free_execi;
|
obj->callbacks.free = &free_execi;
|
||||||
END OBJ(pre_exec, 0)
|
END OBJ(pre_exec, 0)
|
||||||
scan_pre_exec_arg(obj, arg);
|
scan_pre_exec_arg(obj, arg);
|
||||||
|
55
src/exec.cc
55
src/exec.cc
@ -249,7 +249,7 @@ void scan_execi_arg(struct text_object *obj, const char *arg)
|
|||||||
|
|
||||||
if (sscanf(arg, "%f %n", &ed->interval, &n) <= 0) {
|
if (sscanf(arg, "%f %n", &ed->interval, &n) <= 0) {
|
||||||
NORM_ERR("${execi* <interval> command}");
|
NORM_ERR("${execi* <interval> command}");
|
||||||
free(ed);
|
delete ed;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ed->cmd = strndup(arg + n, text_buffer_size);
|
ed->cmd = strndup(arg + n, text_buffer_size);
|
||||||
@ -289,54 +289,36 @@ void scan_execgraph_arg(struct text_object *obj, const char *arg)
|
|||||||
}
|
}
|
||||||
#endif /* BUILD_X11 */
|
#endif /* BUILD_X11 */
|
||||||
|
|
||||||
void print_exec(struct text_object *obj, char *p, int p_max_size)
|
void fill_p(char *buffer, struct text_object *obj, char *p, int p_max_size) {
|
||||||
{
|
if(obj->parse == true) {
|
||||||
read_exec(obj->data.s, p, p_max_size);
|
struct text_object subroot;
|
||||||
|
parse_conky_vars(&subroot, buffer, p, p_max_size);
|
||||||
|
free_text_objects(&subroot);
|
||||||
|
} else snprintf(p, p_max_size, "%s", buffer);
|
||||||
remove_deleted_chars(p);
|
remove_deleted_chars(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_execp(struct text_object *obj, char *p, int p_max_size)
|
void print_exec(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct text_object subroot;
|
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
buf = (char*)malloc(text_buffer_size);
|
buf = (char*)malloc(text_buffer_size);
|
||||||
memset(buf, 0, text_buffer_size);
|
memset(buf, 0, text_buffer_size);
|
||||||
|
|
||||||
read_exec(obj->data.s, buf, text_buffer_size);
|
read_exec(obj->data.s, buf, text_buffer_size);
|
||||||
parse_conky_vars(&subroot, buf, p, p_max_size);
|
fill_p(buf, obj, p, p_max_size);
|
||||||
|
|
||||||
free_text_objects(&subroot);
|
|
||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_execi(struct text_object *obj, char *p, int p_max_size)
|
void print_execi(struct text_object *obj, char *p, int p_max_size)
|
||||||
{
|
{
|
||||||
struct execi_data *ed = (struct execi_data *)obj->data.opaque;
|
struct execi_data *ed = (struct execi_data *)obj->data.opaque;
|
||||||
|
bool fillbuffer = true;
|
||||||
|
|
||||||
if (!ed)
|
if (!ed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (time_to_update(ed)) {
|
if(obj->thread == true) {
|
||||||
if (!ed->buffer)
|
|
||||||
ed->buffer = (char*)malloc(text_buffer_size);
|
|
||||||
read_exec(ed->cmd, ed->buffer, text_buffer_size);
|
|
||||||
ed->last_update = current_update_time;
|
|
||||||
}
|
|
||||||
if(obj->parse == true) {
|
|
||||||
struct text_object subroot;
|
|
||||||
parse_conky_vars(&subroot, ed->buffer, p, p_max_size);
|
|
||||||
free_text_objects(&subroot);
|
|
||||||
} else snprintf(p, p_max_size, "%s", ed->buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void print_texeci(struct text_object *obj, char *p, int p_max_size)
|
|
||||||
{
|
|
||||||
struct execi_data *ed = (struct execi_data *)obj->data.opaque;
|
|
||||||
|
|
||||||
if (!ed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!ed->p_timed_thread) {
|
if (!ed->p_timed_thread) {
|
||||||
/*
|
/*
|
||||||
* note that we don't register this thread with the
|
* note that we don't register this thread with the
|
||||||
@ -346,14 +328,19 @@ void print_texeci(struct text_object *obj, char *p, int p_max_size)
|
|||||||
if (!ed->p_timed_thread) {
|
if (!ed->p_timed_thread) {
|
||||||
NORM_ERR("Error creating texeci timed thread");
|
NORM_ERR("Error creating texeci timed thread");
|
||||||
}
|
}
|
||||||
|
fillbuffer = false;
|
||||||
} else {
|
} else {
|
||||||
std::lock_guard<std::mutex> lock(ed->p_timed_thread->mutex());
|
std::lock_guard<std::mutex> lock(ed->p_timed_thread->mutex());
|
||||||
if(obj->parse == true) {
|
|
||||||
struct text_object subroot;
|
|
||||||
parse_conky_vars(&subroot, ed->buffer, p, p_max_size);
|
|
||||||
free_text_objects(&subroot);
|
|
||||||
} else snprintf(p, p_max_size, "%s", ed->buffer);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (time_to_update(ed)) {
|
||||||
|
if (!ed->buffer)
|
||||||
|
ed->buffer = (char*)malloc(text_buffer_size);
|
||||||
|
read_exec(ed->cmd, ed->buffer, text_buffer_size);
|
||||||
|
ed->last_update = current_update_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(fillbuffer) fill_p(ed->buffer, obj, p, p_max_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
double execbarval(struct text_object *obj)
|
double execbarval(struct text_object *obj)
|
||||||
|
@ -96,6 +96,7 @@ struct text_object {
|
|||||||
long line;
|
long line;
|
||||||
struct obj_cb callbacks;
|
struct obj_cb callbacks;
|
||||||
bool parse; //if this true then data.s should still be parsed
|
bool parse; //if this true then data.s should still be parsed
|
||||||
|
bool thread; //if this true then data.s should be set by a seperate thread
|
||||||
};
|
};
|
||||||
|
|
||||||
/* text object list helpers */
|
/* text object list helpers */
|
||||||
|
Loading…
Reference in New Issue
Block a user