mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
scan_graph: allow giving a "hint" about a good scale value
This is more or less a temporary fix to restore the former behaviour. In the long term objects will define a max value, which will be of use for all kinds of meters.
This commit is contained in:
parent
c88d01af95
commit
e909cdd4eb
@ -448,7 +448,7 @@ void scan_loadgraph_arg(struct text_object *obj, const char *arg)
|
||||
{
|
||||
char *buf = 0;
|
||||
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 0);
|
||||
if (buf)
|
||||
free(buf);
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
END OBJ(cpugraph, &update_cpu_usage)
|
||||
char *buf = 0;
|
||||
SCAN_CPU(arg, obj->data.i);
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 100);
|
||||
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
|
||||
if (buf) free(buf);
|
||||
END OBJ(loadgraph, &update_load_average)
|
||||
@ -613,7 +613,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
#ifdef X11
|
||||
END OBJ(memgraph, &update_meminfo)
|
||||
char *buf = 0;
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 100);
|
||||
|
||||
if (buf) free(buf);
|
||||
#endif /* X11*/
|
||||
@ -902,7 +902,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
#ifdef X11
|
||||
END OBJ_ARG(lua_graph, 0, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]")
|
||||
char *buf = 0;
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 0);
|
||||
if (buf) {
|
||||
obj->data.s = buf;
|
||||
} else {
|
||||
@ -984,7 +984,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
|
||||
#ifdef X11
|
||||
END OBJ(apcupsd_loadgraph, &update_apcupsd)
|
||||
char* buf = 0;
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 0);
|
||||
if (buf) free(buf);
|
||||
END OBJ(apcupsd_loadgauge, &update_apcupsd)
|
||||
scan_gauge(obj, arg);
|
||||
|
@ -143,7 +143,7 @@ void print_diskio(struct text_object *obj, int dir, char *p, int p_max_size)
|
||||
void parse_diskiograph_arg(struct text_object *obj, const char *arg)
|
||||
{
|
||||
char *buf = 0;
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 0);
|
||||
|
||||
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
|
||||
if (buf)
|
||||
|
@ -244,7 +244,7 @@ void scan_execgraph_arg(struct text_object *obj, const char *arg)
|
||||
ed = malloc(sizeof(struct execi_data));
|
||||
memset(ed, 0, sizeof(struct execi_data));
|
||||
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 100);
|
||||
if (!buf) {
|
||||
NORM_ERR("missing command argument to execgraph object");
|
||||
return;
|
||||
|
@ -193,7 +193,7 @@ void print_addrs(struct text_object *obj, char *p, int p_max_size)
|
||||
void parse_net_stat_graph_arg(struct text_object *obj, const char *arg, void *free_at_crash)
|
||||
{
|
||||
char *buf = 0;
|
||||
buf = scan_graph(obj, arg);
|
||||
buf = scan_graph(obj, arg, 0);
|
||||
|
||||
// default to DEFAULTNETDEV
|
||||
if (buf) {
|
||||
|
@ -145,7 +145,7 @@ char *scan_font(const char *args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char *scan_graph(struct text_object *obj, const char *args)
|
||||
char *scan_graph(struct text_object *obj, const char *args, int defscale)
|
||||
{
|
||||
struct graph *g;
|
||||
char buf[1024];
|
||||
@ -160,7 +160,7 @@ char *scan_graph(struct text_object *obj, const char *args)
|
||||
g->height = default_graph_height;
|
||||
g->first_colour = 0;
|
||||
g->last_colour = 0;
|
||||
g->scale = 0;
|
||||
g->scale = defscale;
|
||||
g->tempgrad = FALSE;
|
||||
g->showaslog = FALSE;
|
||||
if (args) {
|
||||
@ -173,14 +173,14 @@ char *scan_graph(struct text_object *obj, const char *args)
|
||||
if (sscanf(args, "%d,%d %x %x %u", &g->height, &g->width, &g->first_colour, &g->last_colour, &g->scale) == 5) {
|
||||
return NULL;
|
||||
}
|
||||
g->scale = 0;
|
||||
g->scale = defscale;
|
||||
if (sscanf(args, "%d,%d %x %x", &g->height, &g->width, &g->first_colour, &g->last_colour) == 4) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(args, "%1023s %d,%d %x %x %u", buf, &g->height, &g->width, &g->first_colour, &g->last_colour, &g->scale) == 6) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
g->scale = 0;
|
||||
g->scale = defscale;
|
||||
if (sscanf(args, "%1023s %d,%d %x %x", buf, &g->height, &g->width, &g->first_colour, &g->last_colour) == 5) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
@ -190,14 +190,14 @@ char *scan_graph(struct text_object *obj, const char *args)
|
||||
if (sscanf(args, "%x %x %u", &g->first_colour, &g->last_colour, &g->scale) == 3) {
|
||||
return NULL;
|
||||
}
|
||||
g->scale = 0;
|
||||
g->scale = defscale;
|
||||
if (sscanf(args, "%x %x", &g->first_colour, &g->last_colour) == 2) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(args, "%1023s %x %x %u", buf, &g->first_colour, &g->last_colour, &g->scale) == 4) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
g->scale = 0;
|
||||
g->scale = defscale;
|
||||
if (sscanf(args, "%1023s %x %x", buf, &g->first_colour, &g->last_colour) == 3) {
|
||||
return strndup(buf, text_buffer_size);
|
||||
}
|
||||
@ -207,12 +207,12 @@ char *scan_graph(struct text_object *obj, const char *args)
|
||||
if (sscanf(args, "%d,%d %u", &g->height, &g->width, &g->scale) == 3) {
|
||||
return NULL;
|
||||
}
|
||||
g->scale = 0;
|
||||
g->scale = defscale;
|
||||
if (sscanf(args, "%d,%d", &g->height, &g->width) == 2) {
|
||||
return NULL;
|
||||
}
|
||||
if (sscanf(args, "%1023s %d,%d %u", buf, &g->height, &g->width, &g->scale) < 4) {
|
||||
g->scale = 0;
|
||||
g->scale = defscale;
|
||||
//TODO: check the return value and throw an error?
|
||||
sscanf(args, "%1023s %d,%d", buf, &g->height, &g->width);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ const char *scan_bar(struct text_object *, const char *);
|
||||
#ifdef X11
|
||||
const char *scan_gauge(struct text_object *, const char *);
|
||||
char *scan_font(const char *);
|
||||
char *scan_graph(struct text_object *, const char *);
|
||||
char *scan_graph(struct text_object *, const char *, int);
|
||||
void scan_tab(struct text_object *, const char *);
|
||||
void scan_stippled_hr(struct text_object *, const char*);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user