1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 04:32:55 +00:00

Allow method to pass execgraph arguments containing spaces.

This commit is contained in:
Brenden Matthews 2010-10-05 12:26:52 -07:00
parent 52e86f4bf6
commit f679b4d22a
2 changed files with 18 additions and 1 deletions

View File

@ -1000,7 +1000,11 @@
use a temperature gradient, which makes the gradient values use a temperature gradient, which makes the gradient values
change depending on the amplitude of a particular graph change depending on the amplitude of a particular graph
value (try it and see). If -t or -l is your first argument, value (try it and see). If -t or -l is your first argument,
you may need to preceed it by a space (' '). you may need to preceed it by a space (' '). You may also use
double-quotes around the exec argument should you need to execute a
command with spaces. For example, ${execgraph "date +'%S'"} to execute
`date +'%S'` and graph the result. Without quotes, it would simply
print the result of `date`.
<para /></listitem> <para /></listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>

View File

@ -214,6 +214,19 @@ char *scan_graph(struct text_object *obj, const char *args, int defscale)
//TODO: check the return value and throw an error? //TODO: check the return value and throw an error?
sscanf(args, "%1023s %d,%d", buf, &g->height, &g->width); sscanf(args, "%1023s %d,%d", buf, &g->height, &g->width);
} }
/* escape quotes at end in case of execgraph */
if (*buf == '"') {
char *_ptr;
size_t _size;
if (_ptr = strrchr(args, '"')) {
_size = _ptr - args - 1;
}
_size = _size < 1024 ? _size : 1023;
strncpy(buf, args + 1, _size);
buf[_size] = 0;
}
#undef g #undef g
return strndup(buf, text_buffer_size); return strndup(buf, text_buffer_size);