mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 20:44:56 +00:00
add eval object, evaluating it's args
This object makes use of the possibility to escape dollar signs in TEXT. Take the following example in the conkyrc: | $${downspeed ${gw_iface}} will be evaluated to (assuming the gw_iface is eth0): | ${downspeed eth0} and finally interpreted to print the gateway interface's downspeed rate.
This commit is contained in:
parent
12a40fd0a9
commit
2c3d57d841
@ -1,3 +1,6 @@
|
|||||||
|
2009-03-24
|
||||||
|
* Added eval text object to realise double parsing
|
||||||
|
|
||||||
2009-03-16
|
2009-03-16
|
||||||
* Fix bug with wacky netstat values on startup
|
* Fix bug with wacky netstat values on startup
|
||||||
|
|
||||||
|
@ -585,6 +585,16 @@
|
|||||||
<para></para></listitem>
|
<para></para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>
|
||||||
|
<command><option>eval</option></command>
|
||||||
|
<option>string</option>
|
||||||
|
</term>
|
||||||
|
<listitem>
|
||||||
|
Evalutates given string according to the rules of TEXT interpretation, i.e. parsing any contained text object specifications into their output, any occuring '$$' into a single '$' and so on. The output is then being parsed again.
|
||||||
|
<para></para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command><option>exec</option></command>
|
<command><option>exec</option></command>
|
||||||
|
17
src/conky.c
17
src/conky.c
@ -703,6 +703,7 @@ static void free_text_objects(struct text_object *root)
|
|||||||
case OBJ_text:
|
case OBJ_text:
|
||||||
case OBJ_font:
|
case OBJ_font:
|
||||||
case OBJ_image:
|
case OBJ_image:
|
||||||
|
case OBJ_eval:
|
||||||
case OBJ_exec:
|
case OBJ_exec:
|
||||||
case OBJ_execgauge:
|
case OBJ_execgauge:
|
||||||
case OBJ_execbar:
|
case OBJ_execbar:
|
||||||
@ -1412,6 +1413,8 @@ static struct text_object *construct_text_object(const char *s,
|
|||||||
obj_be_ifblock_else(ifblock_opaque, obj);
|
obj_be_ifblock_else(ifblock_opaque, obj);
|
||||||
END OBJ(endif, 0)
|
END OBJ(endif, 0)
|
||||||
obj_be_ifblock_endif(ifblock_opaque, obj);
|
obj_be_ifblock_endif(ifblock_opaque, obj);
|
||||||
|
END OBJ(eval, 0)
|
||||||
|
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
|
||||||
END OBJ(image, 0)
|
END OBJ(image, 0)
|
||||||
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
|
obj->data.s = strndup(arg ? arg : "", text_buffer_size);
|
||||||
#ifdef HAVE_POPEN
|
#ifdef HAVE_POPEN
|
||||||
@ -3517,6 +3520,20 @@ static void generate_text_internal(char *p, int p_max_size,
|
|||||||
}
|
}
|
||||||
#endif /* IMLIB2 */
|
#endif /* IMLIB2 */
|
||||||
|
|
||||||
|
OBJ(eval) {
|
||||||
|
struct information *tmp_info;
|
||||||
|
struct text_object subroot, subroot2;
|
||||||
|
|
||||||
|
tmp_info = malloc(sizeof(struct information));
|
||||||
|
memcpy(tmp_info, cur, sizeof(struct information));
|
||||||
|
parse_conky_vars(&subroot, obj->data.s, p, tmp_info);
|
||||||
|
DBGP("evaluated '%s' to '%s'", obj->data.s, p);
|
||||||
|
parse_conky_vars(&subroot2, p, p, tmp_info);
|
||||||
|
|
||||||
|
free_text_objects(&subroot);
|
||||||
|
free_text_objects(&subroot2);
|
||||||
|
free(tmp_info);
|
||||||
|
}
|
||||||
OBJ(exec) {
|
OBJ(exec) {
|
||||||
read_exec(obj->data.s, p, text_buffer_size);
|
read_exec(obj->data.s, p, text_buffer_size);
|
||||||
remove_deleted_chars(p);
|
remove_deleted_chars(p);
|
||||||
|
@ -91,6 +91,7 @@ enum text_object_type {
|
|||||||
OBJ_downspeedgraph,
|
OBJ_downspeedgraph,
|
||||||
OBJ_else,
|
OBJ_else,
|
||||||
OBJ_endif,
|
OBJ_endif,
|
||||||
|
OBJ_eval,
|
||||||
OBJ_image,
|
OBJ_image,
|
||||||
OBJ_exec,
|
OBJ_exec,
|
||||||
OBJ_execi,
|
OBJ_execi,
|
||||||
|
Loading…
Reference in New Issue
Block a user