mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-14 11:33:14 +00:00
Let execp use fill_p
This commit is contained in:
parent
36ad680a98
commit
c010d7cd00
@ -586,6 +586,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ(execp, 0)
|
||||
scan_exec_arg(obj, arg);
|
||||
obj->verbatim_output = 1;
|
||||
obj->parse = true;
|
||||
obj->callbacks.print = &print_execp;
|
||||
obj->callbacks.free = &free_exec;
|
||||
END OBJ(execbar, 0)
|
||||
@ -618,6 +619,7 @@ 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->callbacks.print = &print_execi;
|
||||
obj->callbacks.free = &free_execi;
|
||||
END OBJ_ARG(execpi, 0, "execpi needs arguments")
|
||||
@ -628,6 +630,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
obj->callbacks.free = &free_execi;
|
||||
END OBJ_ARG(texeci, 0, "texeci needs arguments")
|
||||
scan_execi_arg(obj, arg);
|
||||
obj->parse = false;
|
||||
obj->callbacks.print = &print_texeci;
|
||||
obj->callbacks.free = &free_execi;
|
||||
END OBJ_ARG(texecpi, 0, "texecpi needs arguments")
|
||||
|
25
src/exec.cc
25
src/exec.cc
@ -295,29 +295,26 @@ void print_exec(struct text_object *obj, char *p, int p_max_size)
|
||||
remove_deleted_chars(p);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void print_execp(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 fill_p(struct execi_data *ed, struct text_object *obj, char *p, int p_max_size) {
|
||||
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_execi(struct text_object *obj, char *p, int p_max_size)
|
||||
{
|
||||
struct execi_data *ed = (struct execi_data *)obj->data.opaque;
|
||||
@ -331,7 +328,7 @@ void print_execi(struct text_object *obj, char *p, int p_max_size)
|
||||
read_exec(ed->cmd, ed->buffer, text_buffer_size);
|
||||
ed->last_update = current_update_time;
|
||||
}
|
||||
fill_p(ed, obj, p, p_max_size);
|
||||
fill_p(ed->buffer, obj, p, p_max_size);
|
||||
}
|
||||
|
||||
void print_texeci(struct text_object *obj, char *p, int p_max_size)
|
||||
@ -352,7 +349,7 @@ void print_texeci(struct text_object *obj, char *p, int p_max_size)
|
||||
}
|
||||
} else {
|
||||
std::lock_guard<std::mutex> lock(ed->p_timed_thread->mutex());
|
||||
fill_p(ed, obj, p, p_max_size);
|
||||
fill_p(ed->buffer, obj, p, p_max_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user