Made conky eval useful

November 9, 2015 on 8:44 am | In geeky | No Comments

Conky's eval seems rather useless, at least I couldn't get it do anything I wanted, so I added a little patch to make it more useful (to me):

diff --git a/src/conky.c b/src/conky.c
index 5848b61..8702cea 100644
--- a/src/conky.c
+++ b/src/conky.c
@@ -1103,7 +1103,9 @@ void generate_text_internal(char *p, int p_max_size,
 #endif /* IMLIB2 */
                        OBJ(eval) {
-                               evaluate(obj->data.s, p, p_max_size);
+                               char buffer[max_user_text];
+                               evaluate(obj->data.s, buffer, sizeof(buffer));
+                               evaluate(buffer, p, p_max_size);
                        OBJ(exec) {
                                print_exec(obj, p, p_max_size);

Probably not the best thing ever, but seems to do the trick for me; now I can get the address of the interface connected to the big bad internets with (note: won't work correctly when multiple interfaces with default route):

 ${eval $${addr ${gw_iface}}}

The patch applies against conky 1.9.0, unfortunately not against the heavily rewritten git master.

Update: similar patch I made against the 1.10.x has been merged to upstream conky; yay!

Powered by WordPress.
Entries and comments feeds. Valid XHTML and CSS. ^Top^