mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-30 10:38:36 +00:00
Made downspeedgraph and upspeedgraph use same scaling
This commit is contained in:
parent
ac25fcce8b
commit
82bfeba9bf
@ -352,7 +352,7 @@ void print_no_update(struct text_object *obj, char *p,
|
|||||||
|
|
||||||
#ifdef BUILD_GUI
|
#ifdef BUILD_GUI
|
||||||
void scan_loadgraph_arg(struct text_object *obj, const char *arg) {
|
void scan_loadgraph_arg(struct text_object *obj, const char *arg) {
|
||||||
scan_graph(obj, arg, 0);
|
scan_graph(obj, arg, 0, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
double loadgraphval(struct text_object *obj) {
|
double loadgraphval(struct text_object *obj) {
|
||||||
|
10
src/core.cc
10
src/core.cc
@ -729,7 +729,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|||||||
#ifdef BUILD_GUI
|
#ifdef BUILD_GUI
|
||||||
END OBJ(cpugraph, &update_cpu_usage) get_cpu_count();
|
END OBJ(cpugraph, &update_cpu_usage) get_cpu_count();
|
||||||
SCAN_CPU(arg, obj->data.i);
|
SCAN_CPU(arg, obj->data.i);
|
||||||
scan_graph(obj, arg, 1);
|
scan_graph(obj, arg, 1, FALSE);
|
||||||
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
|
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
|
||||||
obj->callbacks.graphval = &cpu_barval;
|
obj->callbacks.graphval = &cpu_barval;
|
||||||
obj->callbacks.free = &free_cpu;
|
obj->callbacks.free = &free_cpu;
|
||||||
@ -1241,9 +1241,9 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|||||||
END OBJ(memwithbuffersbar, &update_meminfo) scan_bar(obj, arg, 1);
|
END OBJ(memwithbuffersbar, &update_meminfo) scan_bar(obj, arg, 1);
|
||||||
obj->callbacks.barval = &mem_with_buffers_barval;
|
obj->callbacks.barval = &mem_with_buffers_barval;
|
||||||
#ifdef BUILD_GUI
|
#ifdef BUILD_GUI
|
||||||
END OBJ(memgraph, &update_meminfo) scan_graph(obj, arg, 1);
|
END OBJ(memgraph, &update_meminfo) scan_graph(obj, arg, 1, FALSE);
|
||||||
obj->callbacks.graphval = &mem_barval;
|
obj->callbacks.graphval = &mem_barval;
|
||||||
END OBJ(memwithbuffersgraph, &update_meminfo) scan_graph(obj, arg, 1);
|
END OBJ(memwithbuffersgraph, &update_meminfo) scan_graph(obj, arg, 1, FALSE);
|
||||||
obj->callbacks.graphval = &mem_with_buffers_barval;
|
obj->callbacks.graphval = &mem_with_buffers_barval;
|
||||||
#endif /* BUILD_GUI*/
|
#endif /* BUILD_GUI*/
|
||||||
#ifdef HAVE_SOME_SOUNDCARD_H
|
#ifdef HAVE_SOME_SOUNDCARD_H
|
||||||
@ -1825,7 +1825,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|||||||
"lua_graph needs arguments: <function name> [height],[width] [gradient "
|
"lua_graph needs arguments: <function name> [height],[width] [gradient "
|
||||||
"colour 1] [gradient colour 2] [scale] [-t] [-l]") auto [buf, skip] =
|
"colour 1] [gradient colour 2] [scale] [-t] [-l]") auto [buf, skip] =
|
||||||
scan_command(arg);
|
scan_command(arg);
|
||||||
scan_graph(obj, arg + skip, 100);
|
scan_graph(obj, arg + skip, 100, FALSE);
|
||||||
if (buf != nullptr) {
|
if (buf != nullptr) {
|
||||||
obj->data.s = buf;
|
obj->data.s = buf;
|
||||||
} else {
|
} else {
|
||||||
@ -1968,7 +1968,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|||||||
END OBJ(apcupsd_loadbar, &update_apcupsd) scan_bar(obj, arg, 100);
|
END OBJ(apcupsd_loadbar, &update_apcupsd) scan_bar(obj, arg, 100);
|
||||||
obj->callbacks.barval = &apcupsd_loadbarval;
|
obj->callbacks.barval = &apcupsd_loadbarval;
|
||||||
#ifdef BUILD_GUI
|
#ifdef BUILD_GUI
|
||||||
END OBJ(apcupsd_loadgraph, &update_apcupsd) scan_graph(obj, arg, 100);
|
END OBJ(apcupsd_loadgraph, &update_apcupsd) scan_graph(obj, arg, 100, FALSE);
|
||||||
obj->callbacks.graphval = &apcupsd_loadbarval;
|
obj->callbacks.graphval = &apcupsd_loadbarval;
|
||||||
END OBJ(apcupsd_loadgauge, &update_apcupsd) scan_gauge(obj, arg, 100);
|
END OBJ(apcupsd_loadgauge, &update_apcupsd) scan_gauge(obj, arg, 100);
|
||||||
obj->callbacks.gaugeval = &apcupsd_loadbarval;
|
obj->callbacks.gaugeval = &apcupsd_loadbarval;
|
||||||
|
@ -173,7 +173,7 @@ void print_diskio_write(struct text_object *obj, char *p,
|
|||||||
#ifdef BUILD_GUI
|
#ifdef BUILD_GUI
|
||||||
void parse_diskiograph_arg(struct text_object *obj, const char *arg) {
|
void parse_diskiograph_arg(struct text_object *obj, const char *arg) {
|
||||||
auto [buf, skip] = scan_command(arg);
|
auto [buf, skip] = scan_command(arg);
|
||||||
scan_graph(obj, arg + skip, 0);
|
scan_graph(obj, arg + skip, 0, FALSE);
|
||||||
|
|
||||||
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
|
obj->data.opaque = prepare_diskio_stat(dev_name(buf));
|
||||||
free_and_zero(buf);
|
free_and_zero(buf);
|
||||||
|
@ -275,7 +275,7 @@ void scan_exec_arg(struct text_object *obj, const char *arg,
|
|||||||
cmd = scan_gauge(obj, cmd, 100);
|
cmd = scan_gauge(obj, cmd, 100);
|
||||||
} else if ((execflag & EF_GRAPH) != 0u) {
|
} else if ((execflag & EF_GRAPH) != 0u) {
|
||||||
auto [buf, skip] = scan_command(cmd);
|
auto [buf, skip] = scan_command(cmd);
|
||||||
scan_graph(obj, cmd + skip, 100);
|
scan_graph(obj, cmd + skip, 100, FALSE);
|
||||||
cmd = buf;
|
cmd = buf;
|
||||||
if (cmd == nullptr) {
|
if (cmd == nullptr) {
|
||||||
NORM_ERR("error parsing arguments to execgraph object");
|
NORM_ERR("error parsing arguments to execgraph object");
|
||||||
|
@ -334,7 +334,7 @@ void parse_net_stat_graph_arg(struct text_object *obj, const char *arg,
|
|||||||
void *free_at_crash) {
|
void *free_at_crash) {
|
||||||
/* scan arguments and get interface name back */
|
/* scan arguments and get interface name back */
|
||||||
auto [buf, skip] = scan_command(arg);
|
auto [buf, skip] = scan_command(arg);
|
||||||
scan_graph(obj, arg + skip, 0);
|
scan_graph(obj, arg + skip, 0, TRUE);
|
||||||
|
|
||||||
// default to DEFAULTNETDEV
|
// default to DEFAULTNETDEV
|
||||||
if (buf != nullptr) {
|
if (buf != nullptr) {
|
||||||
|
@ -458,7 +458,7 @@ int set_nvidia_query(struct text_object *obj, const char *arg,
|
|||||||
break;
|
break;
|
||||||
case text_node_t::GRAPH: {
|
case text_node_t::GRAPH: {
|
||||||
auto [buf, skip] = scan_command(arg);
|
auto [buf, skip] = scan_command(arg);
|
||||||
scan_graph(obj, arg + skip, 100);
|
scan_graph(obj, arg + skip, 100, FALSE);
|
||||||
arg = buf;
|
arg = buf;
|
||||||
} break;
|
} break;
|
||||||
case text_node_t::GAUGE:
|
case text_node_t::GAUGE:
|
||||||
|
@ -50,6 +50,7 @@ struct special_node *specials = nullptr;
|
|||||||
|
|
||||||
int special_count;
|
int special_count;
|
||||||
int graph_count = 0;
|
int graph_count = 0;
|
||||||
|
double maxspeedval = 1e-47; /* The maximum value among the speed graphs */
|
||||||
|
|
||||||
std::map<int, double *> graphs;
|
std::map<int, double *> graphs;
|
||||||
|
|
||||||
@ -106,6 +107,7 @@ struct graph {
|
|||||||
Colour first_colour, last_colour;
|
Colour first_colour, last_colour;
|
||||||
double scale;
|
double scale;
|
||||||
char tempgrad;
|
char tempgrad;
|
||||||
|
char speedgraph; /* If the current graph is a speed graph */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stippled_hr {
|
struct stippled_hr {
|
||||||
@ -249,7 +251,7 @@ std::pair<char *, size_t> scan_command(const char *s) {
|
|||||||
* @param[in] defscale default scale if no scale argument given
|
* @param[in] defscale default scale if no scale argument given
|
||||||
* @return whether parsing was successful
|
* @return whether parsing was successful
|
||||||
**/
|
**/
|
||||||
bool scan_graph(struct text_object *obj, const char *argstr, double defscale) {
|
bool scan_graph(struct text_object *obj, const char *argstr, double defscale, char speedGraph) {
|
||||||
char first_colour_name[1024] = {'\0'};
|
char first_colour_name[1024] = {'\0'};
|
||||||
char last_colour_name[1024] = {'\0'};
|
char last_colour_name[1024] = {'\0'};
|
||||||
|
|
||||||
@ -267,6 +269,10 @@ bool scan_graph(struct text_object *obj, const char *argstr, double defscale) {
|
|||||||
g->scale = defscale;
|
g->scale = defscale;
|
||||||
g->tempgrad = FALSE;
|
g->tempgrad = FALSE;
|
||||||
|
|
||||||
|
if (speedGraph) {
|
||||||
|
g->speedgraph = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (argstr == nullptr) return false;
|
if (argstr == nullptr) return false;
|
||||||
|
|
||||||
/* set tempgrad to true if '-t' specified.
|
/* set tempgrad to true if '-t' specified.
|
||||||
@ -486,6 +492,10 @@ static void graph_append(struct special_node *graph, double f, char showaslog) {
|
|||||||
if (graph->scaled != 0) {
|
if (graph->scaled != 0) {
|
||||||
graph->scale =
|
graph->scale =
|
||||||
*std::max_element(graph->graph + 0, graph->graph + graph->graph_width);
|
*std::max_element(graph->graph + 0, graph->graph + graph->graph_width);
|
||||||
|
if (graph->speedgraph) {
|
||||||
|
maxspeedval = graph->scale < maxspeedval ? maxspeedval : graph->scale;
|
||||||
|
graph->scale = maxspeedval;
|
||||||
|
}
|
||||||
if (graph->scale < 1e-47) {
|
if (graph->scale < 1e-47) {
|
||||||
/* avoid NaN's when the graph is all-zero (e.g. before the first update)
|
/* avoid NaN's when the graph is all-zero (e.g. before the first update)
|
||||||
* there is nothing magical about 1e-47 here */
|
* there is nothing magical about 1e-47 here */
|
||||||
@ -610,6 +620,10 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (g->speedgraph) {
|
||||||
|
s->speedgraph = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (store_graph_data_explicitly.get(*state)) {
|
if (store_graph_data_explicitly.get(*state)) {
|
||||||
if (s->graph) { s->graph = retrieve_graph(g->id, s->graph_width); }
|
if (s->graph) { s->graph = retrieve_graph(g->id, s->graph_width); }
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ struct special_node {
|
|||||||
Colour last_colour;
|
Colour last_colour;
|
||||||
short font_added;
|
short font_added;
|
||||||
char tempgrad;
|
char tempgrad;
|
||||||
|
char speedgraph;
|
||||||
struct special_node *next;
|
struct special_node *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -97,7 +98,7 @@ const char *scan_gauge(struct text_object *, const char *, double);
|
|||||||
#ifdef BUILD_GUI
|
#ifdef BUILD_GUI
|
||||||
void scan_font(struct text_object *, const char *);
|
void scan_font(struct text_object *, const char *);
|
||||||
std::pair<char *, size_t> scan_command(const char *);
|
std::pair<char *, size_t> scan_command(const char *);
|
||||||
bool scan_graph(struct text_object *, const char *, double);
|
bool scan_graph(struct text_object *, const char *, double, char);
|
||||||
void scan_tab(struct text_object *, const char *);
|
void scan_tab(struct text_object *, const char *);
|
||||||
void scan_stippled_hr(struct text_object *, const char *);
|
void scan_stippled_hr(struct text_object *, const char *);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user