diff --git a/doc/variables.xml b/doc/variables.xml index c0a318d8..fc84de07 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -1782,8 +1782,7 @@ function_name (function parameters) Executes a Lua function with given parameters and - draws a graph. Expects result value to be an integer - between 0 and 100. See also 'lua_load' on how to load + draws a graph. Expects result value to be any number, and by default will scale to show the full range. See also 'lua_load' on how to load scripts. Takes the switch '-t' to use a temperature gradient, which makes the gradient values change depending on the amplitude of a particular graph value (try it and diff --git a/src/conky.c b/src/conky.c index 5695a68e..23621cbe 100644 --- a/src/conky.c +++ b/src/conky.c @@ -4073,7 +4073,7 @@ static void generate_text_internal(char *p, int p_max_size, read_exec(cmd, p, text_buffer_size); barnum = get_barnum(p); - if (barnum >= 0.0) { + if (barnum > 0) { new_graph(p, obj->a, obj->b, obj->c, obj->d, round_to_int(barnum), 100, 1, showaslog, tempgrad); } @@ -4515,7 +4515,7 @@ static void generate_text_internal(char *p, int p_max_size, } OBJ(lua_bar) { int per; - if (llua_getinteger(obj->data.s, &per)) { + if (llua_getnumber(obj->data.s, &per)) { #ifdef X11 if(output_methods & TO_X) { new_bar(p, obj->a, obj->b, (per/100.0 * 255)); @@ -4531,14 +4531,14 @@ static void generate_text_internal(char *p, int p_max_size, #ifdef X11 OBJ(lua_graph) { int per; - if (llua_getinteger(obj->data.s, &per)) { + if (llua_getnumber(obj->data.s, &per)) { new_graph(p, obj->a, obj->b, obj->c, obj->d, - (per/100.0 * 255), 100, 1, obj->char_a, obj->char_b); + per, obj->e, 1, obj->char_a, obj->char_b); } } OBJ(lua_gauge) { int per; - if (llua_getinteger(obj->data.s, &per)) { + if (llua_getnumber(obj->data.s, &per)) { new_gauge(p, obj->a, obj->b, (per/100.0 * 255)); } } diff --git a/src/llua.c b/src/llua.c index 4a0953f0..56aa9539 100644 --- a/src/llua.c +++ b/src/llua.c @@ -165,7 +165,7 @@ char *llua_getstring_read(const char *function, const char *arg) return ret; } -int llua_getinteger(const char *args, int *per) +double llua_getnumber(const char *args, int *per) { char *func; @@ -174,9 +174,9 @@ int llua_getinteger(const char *args, int *per) func = llua_do_call(args, 1); if(func) { if(!lua_isnumber(lua_L, -1)) { - ERR("llua_getinteger: function %s didn't return an integer, result discarded", func); + ERR("llua_getnumber: function %s didn't return a number, result discarded", func); } else { - *per = lua_tointeger(lua_L, -1); + *per = lua_tonumber(lua_L, -1); lua_pop(lua_L, 1); return 1; } diff --git a/src/llua.h b/src/llua.h index 9f920f4b..80179f53 100644 --- a/src/llua.h +++ b/src/llua.h @@ -30,7 +30,7 @@ void llua_init(void); void llua_load(const char *script); char *llua_getstring(const char *args); char *llua_getstring_read(const char *function, const char *arg); -int llua_getinteger(const char *args, int *per); +double llua_getnumber(const char *args, int *per); void llua_close(void); #ifdef HAVE_SYS_INOTIFY_H void llua_inotify_query(int wd, int mask);