mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
Let lua_graph behave more like other graphs.
Changed llua_getinteger() to llua_getnumber() returning a double, so that you can use floating point values in graphs etc. Lua graph will scale like other graphs (except execgraph) by default now, and you can manually set a scale with the scale argument.
This commit is contained in:
parent
576d55e473
commit
33754ecebe
@ -1782,8 +1782,7 @@
|
||||
function_name (function parameters)</option>
|
||||
</term>
|
||||
<listitem>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
|
||||
|
10
src/conky.c
10
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));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user