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 */
|
||||
END OBJ(exec, 0)
|
||||
scan_exec_arg(obj, arg);
|
||||
obj->parse = false;
|
||||
obj->thread = false;
|
||||
obj->callbacks.print = &print_exec;
|
||||
obj->callbacks.free = &free_exec;
|
||||
END OBJ(execp, 0)
|
||||
scan_exec_arg(obj, arg);
|
||||
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;
|
||||
END OBJ(execbar, 0)
|
||||
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;
|
||||
END OBJ_ARG(execi, 0, "execi needs arguments")
|
||||
scan_execi_arg(obj, arg);
|
||||
obj->parse = false;
|
||||
obj->thread = false;
|
||||
obj->callbacks.print = &print_execi;
|
||||
obj->callbacks.free = &free_execi;
|
||||
END OBJ_ARG(execpi, 0, "execpi needs arguments")
|
||||
scan_execi_arg(obj, arg);
|
||||
obj->verbatim_output = 1;
|
||||
obj->parse = true;
|
||||
obj->thread = false;
|
||||
obj->callbacks.print = &print_execi;
|
||||
obj->callbacks.free = &free_execi;
|
||||
END OBJ_ARG(texeci, 0, "texeci needs arguments")
|
||||
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;
|
||||
END OBJ_ARG(texecpi, 0, "texecpi needs arguments")
|
||||
scan_execi_arg(obj, arg);
|
||||
obj->parse = true;
|
||||
obj->callbacks.print = &print_texeci;
|
||||
obj->thread = true;
|
||||
obj->callbacks.print = &print_execi;
|
||||
obj->callbacks.free = &free_execi;
|
||||
END OBJ(pre_exec, 0)
|
||||
scan_pre_exec_arg(obj, arg);
|
||||
|
71
src/exec.cc
71
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) {
|
||||
NORM_ERR("${execi* <interval> command}");
|
||||
free(ed);
|
||||
delete ed;
|
||||
return;
|
||||
}
|
||||
ed->cmd = strndup(arg + n, text_buffer_size);
|
||||
@ -289,71 +289,58 @@ void scan_execgraph_arg(struct text_object *obj, const char *arg)
|
||||
}
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
void print_exec(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
read_exec(obj->data.s, p, p_max_size);
|
||||
void fill_p(char *buffer, struct text_object *obj, char *p, int p_max_size) {
|
||||
if(obj->parse == true) {
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
buf = (char*)malloc(text_buffer_size);
|
||||
memset(buf, 0, text_buffer_size);
|
||||
|
||||
read_exec(obj->data.s, buf, text_buffer_size);
|
||||
parse_conky_vars(&subroot, buf, p, p_max_size);
|
||||
|
||||
free_text_objects(&subroot);
|
||||
fill_p(buf, obj, p, p_max_size);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
void print_execi(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
struct execi_data *ed = (struct execi_data *)obj->data.opaque;
|
||||
bool fillbuffer = true;
|
||||
|
||||
if (!ed)
|
||||
return;
|
||||
|
||||
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(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) {
|
||||
/*
|
||||
* note that we don't register this thread with the
|
||||
* timed_thread list, because we destroy it manually
|
||||
*/
|
||||
ed->p_timed_thread = timed_thread::create(std::bind(threaded_exec, std::placeholders::_1, obj), ed->interval * 1000000, false);
|
||||
if(obj->thread == true) {
|
||||
if (!ed->p_timed_thread) {
|
||||
NORM_ERR("Error creating texeci timed thread");
|
||||
/*
|
||||
* note that we don't register this thread with the
|
||||
* timed_thread list, because we destroy it manually
|
||||
*/
|
||||
ed->p_timed_thread = timed_thread::create(std::bind(threaded_exec, std::placeholders::_1, obj), ed->interval * 1000000, false);
|
||||
if (!ed->p_timed_thread) {
|
||||
NORM_ERR("Error creating texeci timed thread");
|
||||
}
|
||||
fillbuffer = false;
|
||||
} else {
|
||||
std::lock_guard<std::mutex> lock(ed->p_timed_thread->mutex());
|
||||
}
|
||||
} else {
|
||||
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);
|
||||
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)
|
||||
|
@ -96,6 +96,7 @@ struct text_object {
|
||||
long line;
|
||||
struct obj_cb callbacks;
|
||||
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 */
|
||||
|
Loading…
Reference in New Issue
Block a user