mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-27 09:08:25 +00:00
Improved parsing of graph arguments.
Removed "log"|"normal" arguments in favour of -l switch.
This commit is contained in:
parent
14d90ad7d1
commit
52c68c094c
@ -1,5 +1,7 @@
|
||||
2009-07-04
|
||||
* Remove newline with comment only lines in TEXT
|
||||
* Improved parsing of graph arguments, removed "log"|"normal" arguments in
|
||||
favour of -l switch
|
||||
|
||||
2009-07-01
|
||||
* Fix escaping of comments in TEXT (sf.net #2813390, thanks Nils)
|
||||
|
@ -167,8 +167,8 @@
|
||||
<command>
|
||||
<option>apcupsd_loadgraph</option>
|
||||
</command>
|
||||
<option>("normal"|"log") (height),(width) (gradient
|
||||
colour 1) (gradient colour 2) (scale) (-t)</option>
|
||||
<option>(height),(width) (gradient colour 1) (gradient
|
||||
colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>History graph of current load.
|
||||
<para /></listitem>
|
||||
@ -637,17 +637,16 @@
|
||||
<command>
|
||||
<option>cpugraph</option>
|
||||
</command>
|
||||
<option>(cpuN) ("normal"|"log") (height),(width)
|
||||
(gradient colour 1) (gradient colour 2) (scale)
|
||||
(-t)</option>
|
||||
<option>(cpuN) (height),(width) (gradient colour 1)
|
||||
(gradient colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>CPU usage graph, with optional colours in hex,
|
||||
minus the #. See $cpu for more info on SMP. Uses a
|
||||
logarithmic scale (to see small numbers) when you use "log"
|
||||
instead of "normal". 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 see).
|
||||
logarithmic scale (to see small numbers) when you use the
|
||||
-l switch. 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
|
||||
see).
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -701,15 +700,14 @@
|
||||
<command>
|
||||
<option>diskiograph</option>
|
||||
</command>
|
||||
<option>(device) ("normal"|"log") (height),(width)
|
||||
(gradient colour 1) (gradient colour 2) (scale)
|
||||
(-t)</option>
|
||||
<option>(device) (height),(width) (gradient colour 1)
|
||||
(gradient colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Disk IO graph, colours defined in hex, minus the
|
||||
#. If scale is non-zero, it becomes the scale for the
|
||||
graph. Uses a logarithmic scale (to see small numbers) when
|
||||
you use "log" instead of "normal". Takes the switch '-t' to
|
||||
use a temperature gradient, which makes the gradient values
|
||||
you use -l switch. 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 see).
|
||||
<para /></listitem>
|
||||
@ -719,18 +717,16 @@
|
||||
<command>
|
||||
<option>diskiograph_read</option>
|
||||
</command>
|
||||
<option>(device) ("normal"|"log") (height),(width)
|
||||
(gradient colour 1) (gradient colour 2) (scale)
|
||||
(-t)</option>
|
||||
<option>(device) (height),(width) (gradient colour 1)
|
||||
(gradient colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Disk IO graph for reads, colours defined in hex,
|
||||
minus the #. If scale is non-zero, it becomes the scale for
|
||||
the graph. Device as in diskio. Uses a logarithmic scale
|
||||
(to see small numbers) when you use "log" instead of
|
||||
"normal". 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
|
||||
see).
|
||||
(to see small numbers) when you use -l switch. 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 see).
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -738,18 +734,16 @@
|
||||
<command>
|
||||
<option>diskiograph_write</option>
|
||||
</command>
|
||||
<option>(device) ("normal"|"log") (height),(width)
|
||||
(gradient colour 1) (gradient colour 2) (scale)
|
||||
(-t)</option>
|
||||
<option>(device) (height),(width) (gradient colour 1)
|
||||
(gradient colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Disk IO graph for writes, colours defined in hex,
|
||||
minus the #. If scale is non-zero, it becomes the scale for
|
||||
the graph. Device as in diskio. Uses a logarithmic scale
|
||||
(to see small numbers) when you use "log" instead of
|
||||
"normal". 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
|
||||
see).
|
||||
(to see small numbers) when you use -l switch. 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 see).
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -777,17 +771,16 @@
|
||||
<command>
|
||||
<option>downspeedgraph</option>
|
||||
</command>
|
||||
<option>(netdev) ("normal"|"log") (height),(width)
|
||||
(gradient colour 1) (gradient colour 2) (scale)
|
||||
(-t)</option>
|
||||
<option>(netdev) (height),(width) (gradient colour 1)
|
||||
(gradient colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Download speed graph, colours defined in hex,
|
||||
minus the #. If scale is non-zero, it becomes the scale for
|
||||
the graph. Uses a logarithmic scale (to see small numbers)
|
||||
when you use "log" instead of "normal". 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 see).
|
||||
when you use -l switch. 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 see).
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -932,12 +925,12 @@
|
||||
<command>
|
||||
<option>execgraph</option>
|
||||
</command>
|
||||
<option>("normal"|"log") (-t) command</option>
|
||||
<option>(-t) (-l) command</option>
|
||||
</term>
|
||||
<listitem>Same as execbar, but graphs values. Uses a
|
||||
logaritmic scale when the log option is given (to see small
|
||||
numbers). Values still have to be between 0 and 100. The
|
||||
size for graphs can be controlled via the
|
||||
logaritmic scale when the log option (-l switch) is given
|
||||
(to see small numbers). Values still have to be between 0
|
||||
and 100. The size for graphs can be controlled via the
|
||||
default_graph_size config setting. Takes the switch '-t' to
|
||||
use a temperature gradient, which makes the gradient values
|
||||
change depending on the amplitude of a particular graph
|
||||
@ -982,7 +975,7 @@
|
||||
<command>
|
||||
<option>execigraph</option>
|
||||
</command>
|
||||
<option>interval ("normal"|"log") (-t) command</option>
|
||||
<option>interval (-t) (-l) command</option>
|
||||
</term>
|
||||
<listitem>Same as execgraph, but takes an interval arg and
|
||||
graphs values.
|
||||
@ -1733,16 +1726,15 @@
|
||||
<command>
|
||||
<option>loadgraph</option>
|
||||
</command>
|
||||
<option>("normal"|"log") (height),(width) (gradient
|
||||
colour 1) (gradient colour 2) (scale) (-t)</option>
|
||||
<option>(height),(width) (gradient colour 1) (gradient
|
||||
colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Load1 average graph, similar to xload, with
|
||||
optional colours in hex, minus the #. Uses a logarithmic
|
||||
scale (to see small numbers) when you use "log" instead of
|
||||
"normal". 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
|
||||
see).
|
||||
scale (to see small numbers) when you use the -l switch.
|
||||
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 see).
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -1789,17 +1781,16 @@
|
||||
<command>
|
||||
<option>lua_graph</option>
|
||||
</command>
|
||||
<option>function_name (function parameters)
|
||||
("normal"|"log") (height),(width) (gradient colour 1)
|
||||
(gradient colour 2) (scale) (-t)</option>
|
||||
<option>function_name (height),(width) (gradient colour
|
||||
1) (gradient colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Executes a Lua function with given parameters and
|
||||
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 see).
|
||||
<listitem>Executes a Lua function with and 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
|
||||
see).
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -1922,14 +1913,14 @@
|
||||
<command>
|
||||
<option>memgraph</option>
|
||||
</command>
|
||||
<option>("normal"|"log") (height),(width) (gradient
|
||||
colour 1) (gradient colour 2) (scale) (-t)</option>
|
||||
<option>(height),(width) (gradient colour 1) (gradient
|
||||
colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Memory usage graph. Uses a logarithmic scale (to
|
||||
see small numbers) when you use "log" instead of "normal".
|
||||
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 see).
|
||||
see small numbers) when you use the -l switch. 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 see).
|
||||
<para /></listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
@ -3096,15 +3087,14 @@
|
||||
<command>
|
||||
<option>upspeedgraph</option>
|
||||
</command>
|
||||
<option>(netdev) ("normal"|"log") (height),(width)
|
||||
(gradient colour 1) (gradient colour 2) (scale)
|
||||
(-t)</option>
|
||||
<option>(netdev) (height),(width) (gradient colour 1)
|
||||
(gradient colour 2) (scale) (-t) (-l)</option>
|
||||
</term>
|
||||
<listitem>Upload speed graph, colours defined in hex, minus
|
||||
the #. If scale is non-zero, it becomes the scale for the
|
||||
graph. Uses a logarithmic scale (to see small numbers) when
|
||||
you use "log" instead of "normal". Takes the switch '-t' to
|
||||
use a temperature gradient, which makes the gradient values
|
||||
you use the -l switch. 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 see).
|
||||
<para /></listitem>
|
||||
|
24
src/conky.c
24
src/conky.c
@ -2825,10 +2825,10 @@ static struct text_object *construct_text_object(const char *s,
|
||||
if (buf) {
|
||||
obj->data.s = buf;
|
||||
} else {
|
||||
CRIT_ERR("lua_graph needs arguments: <\"normal\"|\"log\"> <height>,<width> <gradient colour 1> <gradient colour 2> <scale> <function name> [function parameters]");
|
||||
CRIT_ERR("lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
|
||||
}
|
||||
} else {
|
||||
CRIT_ERR("lua_graph needs arguments: <\"normal\"|\"log\"> <height>,<width> <gradient colour 1> <gradient colour 2> <scale> <function name> [function parameters]");
|
||||
CRIT_ERR("lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
|
||||
}
|
||||
END OBJ(lua_gauge, 0)
|
||||
SIZE_DEFAULTS(gauge);
|
||||
@ -4192,16 +4192,14 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
double barnum;
|
||||
char *cmd = obj->data.s;
|
||||
|
||||
if (strncasecmp(obj->data.execi.cmd, LOGGRAPH" ", strlen(LOGGRAPH" ")) == EQUAL) {
|
||||
showaslog = TRUE;
|
||||
cmd = cmd + strlen(LOGGRAPH" ") * sizeof(char);
|
||||
} else if(strncasecmp(obj->data.s, NORMGRAPH" ", strlen(NORMGRAPH" ")) == EQUAL) {
|
||||
cmd = cmd + strlen(NORMGRAPH" ") * sizeof(char);
|
||||
}
|
||||
if (strstr(cmd, " "TEMPGRAD) && strlen(cmd) > strlen(" "TEMPGRAD)) {
|
||||
tempgrad = TRUE;
|
||||
cmd += strlen(" "TEMPGRAD);
|
||||
}
|
||||
if (strstr(cmd, " "LOGGRAPH) && strlen(cmd) > strlen(" "LOGGRAPH)) {
|
||||
showaslog = TRUE;
|
||||
cmd += strlen(" "LOGGRAPH);
|
||||
}
|
||||
read_exec(cmd, p, text_buffer_size);
|
||||
barnum = get_barnum(p);
|
||||
|
||||
@ -4244,16 +4242,14 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
char tempgrad = FALSE;
|
||||
char *cmd = obj->data.execi.cmd;
|
||||
|
||||
if (strncasecmp(obj->data.execi.cmd, LOGGRAPH" ", strlen(LOGGRAPH" ")) == EQUAL) {
|
||||
showaslog = TRUE;
|
||||
cmd = cmd + strlen(LOGGRAPH" ") * sizeof(char);
|
||||
} else if(strncasecmp(obj->data.s, NORMGRAPH" ", strlen(NORMGRAPH" ")) == EQUAL) {
|
||||
cmd = cmd + strlen(NORMGRAPH" ") * sizeof(char);
|
||||
}
|
||||
if (strstr(cmd, " "TEMPGRAD) && strlen(cmd) > strlen(" "TEMPGRAD)) {
|
||||
tempgrad = TRUE;
|
||||
cmd += strlen(" "TEMPGRAD);
|
||||
}
|
||||
if (strstr(cmd, " "LOGGRAPH) && strlen(cmd) > strlen(" "LOGGRAPH)) {
|
||||
showaslog = TRUE;
|
||||
cmd += strlen(" "LOGGRAPH);
|
||||
}
|
||||
obj->char_a = showaslog;
|
||||
obj->char_b = tempgrad;
|
||||
read_exec(cmd, p, text_buffer_size);
|
||||
|
@ -107,9 +107,8 @@ char *scan_graph(const char *args, int *w, int *h,
|
||||
unsigned int *first_colour, unsigned int *last_colour,
|
||||
unsigned int *scale, char *showaslog, char *tempgrad)
|
||||
{
|
||||
const char *nographtype;
|
||||
char buf[64];
|
||||
buf[0] = 0;
|
||||
char buf[1024];
|
||||
memset(buf, 0, 1024);
|
||||
|
||||
/* zero width means all space that is available */
|
||||
*w = default_graph_width;
|
||||
@ -118,74 +117,61 @@ char *scan_graph(const char *args, int *w, int *h,
|
||||
*last_colour = 0;
|
||||
*scale = 0;
|
||||
*tempgrad = FALSE;
|
||||
*showaslog = FALSE;
|
||||
if (args) {
|
||||
// set showaslog and place the rest of the args in nographtype
|
||||
if (strcasecmp(args, LOGGRAPH) == EQUAL) {
|
||||
*showaslog = TRUE;
|
||||
return NULL;
|
||||
} else if (strcasecmp(args, NORMGRAPH) == EQUAL) {
|
||||
*showaslog = FALSE;
|
||||
return NULL;
|
||||
} else if (strncasecmp(args, LOGGRAPH" ", strlen(LOGGRAPH) + 1 ) == EQUAL) {
|
||||
*showaslog = TRUE;
|
||||
nographtype = &args[strlen(LOGGRAPH) + 1];
|
||||
} else if (strncasecmp(args, NORMGRAPH" ", strlen(NORMGRAPH) + 1 ) == EQUAL) {
|
||||
*showaslog = FALSE;
|
||||
nographtype = &args[strlen(NORMGRAPH) + 1];
|
||||
} else {
|
||||
*showaslog = FALSE;
|
||||
nographtype = args;
|
||||
}
|
||||
if (strstr(args, " "TEMPGRAD)) {
|
||||
*tempgrad = TRUE;
|
||||
}
|
||||
DBGP("printing graph as %s, other args are: %s", (*showaslog ? "log" : "normal"), nographtype);
|
||||
if (strstr(args, " "LOGGRAPH)) {
|
||||
*showaslog = TRUE;
|
||||
}
|
||||
DBGP("printing graph as %s, other args are: %s", (*showaslog ? "log" : "normal"), args);
|
||||
//check the rest of the args
|
||||
if (sscanf(nographtype, "%d,%d %x %x %u", h, w, first_colour, last_colour, scale) == 5) {
|
||||
if (sscanf(args, "%d,%d %x %x %u", h, w, first_colour, last_colour, scale) == 5) {
|
||||
return NULL;
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(nographtype, "%d,%d %x %x", h, w, first_colour, last_colour) == 4) {
|
||||
if (sscanf(args, "%d,%d %x %x", h, w, first_colour, last_colour) == 4) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(nographtype, "%63s %d,%d %x %x %u", buf, h, w, first_colour, last_colour, scale) == 6) {
|
||||
if (sscanf(args, "%1023s %d,%d %x %x %u", buf, h, w, first_colour, last_colour, scale) == 6) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(nographtype, "%63s %d,%d %x %x", buf, h, w, first_colour, last_colour) == 5) {
|
||||
if (sscanf(args, "%1023s %d,%d %x %x", buf, h, w, first_colour, last_colour) == 5) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
buf[0] = '\0';
|
||||
*h = 25;
|
||||
*w = 0;
|
||||
if (sscanf(nographtype, "%x %x %u", first_colour, last_colour, scale) == 3) {
|
||||
if (sscanf(args, "%x %x %u", first_colour, last_colour, scale) == 3) {
|
||||
return NULL;
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(nographtype, "%x %x", first_colour, last_colour) == 2) {
|
||||
if (sscanf(args, "%x %x", first_colour, last_colour) == 2) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(nographtype, "%63s %x %x %u", buf, first_colour, last_colour, scale) == 4) {
|
||||
if (sscanf(args, "%1023s %x %x %u", buf, first_colour, last_colour, scale) == 4) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(nographtype, "%63s %x %x", buf, first_colour, last_colour) == 3) {
|
||||
if (sscanf(args, "%1023s %x %x", buf, first_colour, last_colour) == 3) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
buf[0] = '\0';
|
||||
*first_colour = 0;
|
||||
*last_colour = 0;
|
||||
if (sscanf(nographtype, "%d,%d %u", h, w, scale) == 3) {
|
||||
if (sscanf(args, "%d,%d %u", h, w, scale) == 3) {
|
||||
return NULL;
|
||||
}
|
||||
*scale = 0;
|
||||
if (sscanf(nographtype, "%d,%d", h, w) == 2) {
|
||||
if (sscanf(args, "%d,%d", h, w) == 2) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(nographtype, "%63s %d,%d %u", buf, h, w, scale) < 4) {
|
||||
if (sscanf(args, "%1023s %d,%d %u", buf, h, w, scale) < 4) {
|
||||
*scale = 0;
|
||||
//TODO: check the return value and throw an error?
|
||||
sscanf(nographtype, "%63s %d,%d", buf, h, w);
|
||||
sscanf(args, "%1023s %d,%d", buf, h, w);
|
||||
}
|
||||
|
||||
return strndup(buf, text_buffer_size);
|
||||
|
@ -34,8 +34,7 @@
|
||||
#define MAX_GRAPH_DEPTH 512
|
||||
|
||||
// don't use spaces in LOGGRAPH or NORMGRAPH if you change them
|
||||
#define LOGGRAPH "log"
|
||||
#define NORMGRAPH "normal"
|
||||
#define LOGGRAPH "-l"
|
||||
#define TEMPGRAD "-t"
|
||||
|
||||
enum special_types {
|
||||
|
Loading…
x
Reference in New Issue
Block a user