mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-16 04:02:15 +00:00
Implemented graph value clamping (#2000)
* Implemented graph value clamping * Update variables.yaml * Update variables.yaml
This commit is contained in:
parent
7ec86cfbd8
commit
e03891f993
@ -99,6 +99,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: apcupsd_model
|
- name: apcupsd_model
|
||||||
desc: Prints the model of the UPS.
|
desc: Prints the model of the UPS.
|
||||||
- name: apcupsd_name
|
- name: apcupsd_name
|
||||||
@ -331,7 +332,9 @@ values:
|
|||||||
numbers) when you use the -l switch. Takes the switch '-t' to use a
|
numbers) when you use the -l switch. Takes the switch '-t' to use a
|
||||||
temperature gradient, which makes the gradient values change depending
|
temperature gradient, which makes the gradient values change depending
|
||||||
on the amplitude of a particular graph value (try it and see). The flag
|
on the amplitude of a particular graph value (try it and see). The flag
|
||||||
'-x' inverts the x axis and '-y' inverts the y axis of the graph.
|
'-x' inverts the x axis and '-y' inverts the y axis of the graph. The flag
|
||||||
|
'-m' sets a nonzero minimum/lowerbound, ensuring that all values are at
|
||||||
|
least the specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (cpuN)
|
- (cpuN)
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
@ -342,6 +345,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: curl
|
- name: curl
|
||||||
desc: |-
|
desc: |-
|
||||||
Download data from URI using Curl at the specified interval.
|
Download data from URI using Curl at the specified interval.
|
||||||
@ -395,7 +399,8 @@ values:
|
|||||||
'-t' to use a temperature gradient, which makes the gradient values
|
'-t' to use a temperature gradient, which makes the gradient values
|
||||||
change depending on the amplitude of a particular graph value (try it
|
change depending on the amplitude of a particular graph value (try it
|
||||||
and see). The flag '-x' inverts the x axis and '-y' inverts the y axis
|
and see). The flag '-x' inverts the x axis and '-y' inverts the y axis
|
||||||
of the graph.
|
of the graph. The flag '-m' sets a nonzero minimum/lowerbound, ensuring
|
||||||
|
that all values are at least the specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (device)
|
- (device)
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
@ -406,6 +411,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: diskiograph_read
|
- name: diskiograph_read
|
||||||
desc: |-
|
desc: |-
|
||||||
Disk IO graph for reads, colours defined in hex, minus the
|
Disk IO graph for reads, colours defined in hex, minus the
|
||||||
@ -414,7 +420,9 @@ values:
|
|||||||
use -l switch. Takes the switch '-t' to use a temperature gradient,
|
use -l switch. Takes the switch '-t' to use a temperature gradient,
|
||||||
which makes the gradient values change depending on the amplitude of a
|
which makes the gradient values change depending on the amplitude of a
|
||||||
particular graph value (try it and see). The flag '-x' inverts the x
|
particular graph value (try it and see). The flag '-x' inverts the x
|
||||||
axis and '-y' inverts the y axis of the graph.
|
axis and '-y' inverts the y axis of the graph. The flag '-m' sets a nonzero
|
||||||
|
minimum/lowerbound, ensuring that all values are at least the specified
|
||||||
|
minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (device)
|
- (device)
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
@ -425,6 +433,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: diskiograph_write
|
- name: diskiograph_write
|
||||||
desc: |-
|
desc: |-
|
||||||
Disk IO graph for writes, colours defined in hex, minus the
|
Disk IO graph for writes, colours defined in hex, minus the
|
||||||
@ -433,7 +442,9 @@ values:
|
|||||||
use -l switch. Takes the switch '-t' to use a temperature gradient,
|
use -l switch. Takes the switch '-t' to use a temperature gradient,
|
||||||
which makes the gradient values change depending on the amplitude of a
|
which makes the gradient values change depending on the amplitude of a
|
||||||
particular graph value (try it and see). The flag '-x' inverts the x
|
particular graph value (try it and see). The flag '-x' inverts the x
|
||||||
axis and '-y' inverts the y axis of the graph.
|
axis and '-y' inverts the y axis of the graph. The flag '-m' sets a
|
||||||
|
nonzero minimum/lowerbound, ensuring that all values are at
|
||||||
|
least the specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (device)
|
- (device)
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
@ -444,6 +455,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: distribution
|
- name: distribution
|
||||||
desc: |-
|
desc: |-
|
||||||
The name of the distribution. It could be that some of the
|
The name of the distribution. It could be that some of the
|
||||||
@ -471,7 +483,9 @@ values:
|
|||||||
-l switch. Takes the switch '-t' to use a temperature gradient, which makes
|
-l switch. Takes the switch '-t' to use a temperature gradient, which makes
|
||||||
the gradient values change depending on the amplitude of a particular
|
the gradient values change depending on the amplitude of a particular
|
||||||
graph value (try it and see). The flag '-x' inverts the x axis and '-y'
|
graph value (try it and see). The flag '-x' inverts the x axis and '-y'
|
||||||
inverts the y axis of the graph.
|
inverts the y axis of the graph. The flag '-m' sets a nonzero
|
||||||
|
minimum/lowerbound, ensuring that all values are at least the specified
|
||||||
|
minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (netdev)
|
- (netdev)
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
@ -482,6 +496,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m)
|
||||||
- name: draft_mails
|
- name: draft_mails
|
||||||
desc: |-
|
desc: |-
|
||||||
Number of mails marked as draft in the specified mailbox or
|
Number of mails marked as draft in the specified mailbox or
|
||||||
@ -553,7 +568,9 @@ values:
|
|||||||
-l switch to enable a logarithmic scale, which helps to see small values.
|
-l switch to enable a logarithmic scale, which helps to see small values.
|
||||||
The default size for graphs can be controlled via the default_graph_height
|
The default size for graphs can be controlled via the default_graph_height
|
||||||
and default_graph_width config settings. The flag '-x' inverts the x axis
|
and default_graph_width config settings. The flag '-x' inverts the x axis
|
||||||
and '-y' inverts the y axis of the graph.
|
and '-y' inverts the y axis of the graph. The flag '-m' sets a nonzero
|
||||||
|
minimum/lowerbound, ensuring that all values are at least the specified
|
||||||
|
minimum (excluding zero).
|
||||||
|
|
||||||
If you need to execute a command with spaces, you have a
|
If you need to execute a command with spaces, you have a
|
||||||
couple options:
|
couple options:
|
||||||
@ -582,6 +599,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: execi
|
- name: execi
|
||||||
desc: |-
|
desc: |-
|
||||||
Same as exec, but with a specific interval in seconds. The
|
Same as exec, but with a specific interval in seconds. The
|
||||||
@ -615,6 +633,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: execp
|
- name: execp
|
||||||
desc: |-
|
desc: |-
|
||||||
Executes a shell command and displays the output in conky.
|
Executes a shell command and displays the output in conky.
|
||||||
@ -1135,6 +1154,8 @@ values:
|
|||||||
gradient, which makes the gradient values change depending on the
|
gradient, which makes the gradient values change depending on the
|
||||||
amplitude of a particular graph value (try it and see). The flag
|
amplitude of a particular graph value (try it and see). The flag
|
||||||
'-x' inverts the x axis and '-y' inverts the y axis of the graph.
|
'-x' inverts the x axis and '-y' inverts the y axis of the graph.
|
||||||
|
The flag '-m' sets a nonzero minimum/lowerbound, ensuring that all
|
||||||
|
values are at least the specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
- (gradient colour 1)
|
- (gradient colour 1)
|
||||||
@ -1144,6 +1165,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: lowercase
|
- name: lowercase
|
||||||
desc: Converts all letters into lowercase.
|
desc: Converts all letters into lowercase.
|
||||||
args:
|
args:
|
||||||
@ -1190,7 +1212,9 @@ values:
|
|||||||
(try it and see). Conky puts 'conky_' in front of function_name to
|
(try it and see). Conky puts 'conky_' in front of function_name to
|
||||||
prevent accidental calls to the wrong function unless you put you
|
prevent accidental calls to the wrong function unless you put you
|
||||||
place 'conky_' in front of it yourself. The flag '-x' inverts the
|
place 'conky_' in front of it yourself. The flag '-x' inverts the
|
||||||
x axis and '-y' inverts the y axis of the graph.
|
x axis and '-y' inverts the y axis of the graph. The flag '-m' sets
|
||||||
|
a nonzero minimum/lowerbound, ensuring that all values are at least
|
||||||
|
the specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- function_name
|
- function_name
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
@ -1201,6 +1225,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: lua_parse
|
- name: lua_parse
|
||||||
desc: |-
|
desc: |-
|
||||||
Executes a Lua function with given parameters as per $lua,
|
Executes a Lua function with given parameters as per $lua,
|
||||||
@ -1261,7 +1286,9 @@ values:
|
|||||||
numbers) when you use the -l switch. Takes the switch '-t' to use a
|
numbers) when you use the -l switch. Takes the switch '-t' to use a
|
||||||
temperature gradient, which makes the gradient values change depending
|
temperature gradient, which makes the gradient values change depending
|
||||||
on the amplitude of a particular graph value (try it and see). The flag
|
on the amplitude of a particular graph value (try it and see). The flag
|
||||||
'-x' inverts the x axis and '-y' inverts the y axis of the graph.
|
'-x' inverts the x axis and '-y' inverts the y axis of the graph. The flag
|
||||||
|
'-m' sets a nonzero minimum/lowerbound, ensuring that all values are at
|
||||||
|
least the specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
- (gradient colour 1)
|
- (gradient colour 1)
|
||||||
@ -1271,6 +1298,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: meminactive
|
- name: meminactive
|
||||||
desc: Amount of inactive memory. FreeBSD only.
|
desc: Amount of inactive memory. FreeBSD only.
|
||||||
- name: memlaundry
|
- name: memlaundry
|
||||||
@ -1299,6 +1327,8 @@ values:
|
|||||||
gradient, which makes the gradient values change depending on the
|
gradient, which makes the gradient values change depending on the
|
||||||
amplitude of a particular graph value (try it and see). The flag
|
amplitude of a particular graph value (try it and see). The flag
|
||||||
'-x' inverts the x axis and '-y' inverts the y axis of the graph.
|
'-x' inverts the x axis and '-y' inverts the y axis of the graph.
|
||||||
|
The flag '-m' sets a nonzero minimum/lowerbound, ensuring that all
|
||||||
|
values are at least the specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
- (gradient colour 1)
|
- (gradient colour 1)
|
||||||
@ -1308,6 +1338,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m value)
|
||||||
- name: mixer
|
- name: mixer
|
||||||
desc: |-
|
desc: |-
|
||||||
Prints the mixer value as reported by the OS. On Linux, this
|
Prints the mixer value as reported by the OS. On Linux, this
|
||||||
@ -1574,6 +1605,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m)
|
||||||
- GPU_ID
|
- GPU_ID
|
||||||
- name: offset
|
- name: offset
|
||||||
desc: Move text over by N pixels. See also $voffset.
|
desc: Move text over by N pixels. See also $voffset.
|
||||||
@ -2365,7 +2397,9 @@ values:
|
|||||||
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 value
|
change depending on the amplitude of a particular graph value
|
||||||
(try it and see). The flag '-x' inverts the x axis and '-y'
|
(try it and see). The flag '-x' inverts the x axis and '-y'
|
||||||
inverts the y axis of the graph.
|
inverts the y axis of the graph. The flag '-m' sets a nonzero
|
||||||
|
minimum/lowerbound, ensuring that all values are at least the
|
||||||
|
specified minimum (excluding zero).
|
||||||
args:
|
args:
|
||||||
- (netdev)
|
- (netdev)
|
||||||
- (height),(width)
|
- (height),(width)
|
||||||
@ -2376,6 +2410,7 @@ values:
|
|||||||
- (-l)
|
- (-l)
|
||||||
- (-x)
|
- (-x)
|
||||||
- (-y)
|
- (-y)
|
||||||
|
- (-m)
|
||||||
- name: uptime
|
- name: uptime
|
||||||
desc: Uptime.
|
desc: Uptime.
|
||||||
- name: uptime_short
|
- name: uptime_short
|
||||||
|
@ -998,6 +998,11 @@ static inline void set_foreground_color(Colour c) {
|
|||||||
static inline void draw_graph_bars(special_node *current, std::unique_ptr<Colour[]>& tmpcolour,
|
static inline void draw_graph_bars(special_node *current, std::unique_ptr<Colour[]>& tmpcolour,
|
||||||
conky::vec2i& text_offset, int i, int &j, int w,
|
conky::vec2i& text_offset, int i, int &j, int w,
|
||||||
int colour_idx, int cur_x, int by, int h) {
|
int colour_idx, int cur_x, int by, int h) {
|
||||||
|
double graphheight = current->graph[j] * (h - 1) / current->scale;
|
||||||
|
/* Check if graphheight is less than the minheight threshold, if so we must change it to the threshold */
|
||||||
|
if(graphheight > 0 && current->minheight - graphheight > 0) {
|
||||||
|
current->graph[j] = current->minheight * current->scale / (h - 1);
|
||||||
|
}
|
||||||
if (current->colours_set) {
|
if (current->colours_set) {
|
||||||
if (current->tempgrad != 0) {
|
if (current->tempgrad != 0) {
|
||||||
set_foreground_color(tmpcolour[static_cast<int>(
|
set_foreground_color(tmpcolour[static_cast<int>(
|
||||||
|
@ -113,6 +113,7 @@ struct graph {
|
|||||||
char tempgrad;
|
char tempgrad;
|
||||||
char speedgraph; /* If the current graph is a speed graph */
|
char speedgraph; /* If the current graph is a speed graph */
|
||||||
char invertflag; /* If the axis needs to be inverted */
|
char invertflag; /* If the axis needs to be inverted */
|
||||||
|
int minheight; /* Clamp values below this threshold to this threshold */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct stippled_hr {
|
struct stippled_hr {
|
||||||
@ -246,12 +247,13 @@ std::pair<char *, size_t> scan_command(const char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parses for [height,width] [color1 color2] [scale] [-t] [-l]
|
* parses for [height,width] [color1 color2] [scale] [-t] [-l] [-m value]
|
||||||
*
|
*
|
||||||
* -l will set the showlog flag, enabling logarithmic graph scales
|
* -l will set the showlog flag, enabling logarithmic graph scales
|
||||||
* -t will set the tempgrad member to true, enabling temperature gradient colors
|
* -t will set the tempgrad member to true, enabling temperature gradient colors
|
||||||
* -x will set the invertx flag to true, inverting the x axis
|
* -x will set the invertx flag to true, inverting the x axis
|
||||||
* -y will set the invertx flag to true, inverting the y axis
|
* -y will set the invertx flag to true, inverting the y axis
|
||||||
|
* -m will set the minheight to value, this will clamp values below the threshold to the threshold
|
||||||
*
|
*
|
||||||
* @param[out] obj struct in which to save width, height and other options
|
* @param[out] obj struct in which to save width, height and other options
|
||||||
* @param[in] args argument string to parse
|
* @param[in] args argument string to parse
|
||||||
@ -277,6 +279,7 @@ bool scan_graph(struct text_object *obj, const char *argstr, double defscale, ch
|
|||||||
g->scale = defscale;
|
g->scale = defscale;
|
||||||
g->tempgrad = FALSE;
|
g->tempgrad = FALSE;
|
||||||
g->invertflag = FALSE;
|
g->invertflag = FALSE;
|
||||||
|
g->minheight = 0;
|
||||||
if (speedGraph) {
|
if (speedGraph) {
|
||||||
g->speedgraph = TRUE;
|
g->speedgraph = TRUE;
|
||||||
}
|
}
|
||||||
@ -307,6 +310,34 @@ bool scan_graph(struct text_object *obj, const char *argstr, double defscale, ch
|
|||||||
g->invertflag |= SF_INVERTY;
|
g->invertflag |= SF_INVERTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* set MINHEIGHT to specified value if '-m' specified.
|
||||||
|
* It doesn't matter where the argument is exactly.
|
||||||
|
* Accepted values are from [0-5] */
|
||||||
|
const char *position = strstr(argstr, " " MINHEIGHT);
|
||||||
|
if ((position != nullptr) ||
|
||||||
|
strncmp(argstr, MINHEIGHT, strlen(MINHEIGHT)) == 0) {
|
||||||
|
int minheight = 0;
|
||||||
|
position += strlen(MINHEIGHT) + 1;
|
||||||
|
int size = strlen(argstr);
|
||||||
|
// Avoid whitespaces
|
||||||
|
while(*position == ' ' && position < argstr + size) {
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
// Get the numeric value start and end position
|
||||||
|
const char* numStart = position;
|
||||||
|
while (isdigit(*position)) {
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
// Convert the numeric value to an integer
|
||||||
|
std::string numStr(numStart, position);
|
||||||
|
if (!numStr.empty()) {
|
||||||
|
minheight = atoi(numStr.c_str());
|
||||||
|
}
|
||||||
|
// If specified value is greater than the max threshold
|
||||||
|
minheight = minheight > 5 ? 5 : minheight;
|
||||||
|
g->minheight = minheight;
|
||||||
|
}
|
||||||
|
|
||||||
/* all the following functions try to interpret the beginning of a
|
/* all the following functions try to interpret the beginning of a
|
||||||
* a string with different format strings. If successful, they return from
|
* a string with different format strings. If successful, they return from
|
||||||
* the function */
|
* the function */
|
||||||
@ -652,6 +683,7 @@ void new_graph(struct text_object *obj, char *buf, int buf_max_size,
|
|||||||
s->show_scale = 1;
|
s->show_scale = 1;
|
||||||
}
|
}
|
||||||
s->tempgrad = g->tempgrad;
|
s->tempgrad = g->tempgrad;
|
||||||
|
s->minheight = g->minheight;
|
||||||
#ifdef BUILD_MATH
|
#ifdef BUILD_MATH
|
||||||
if ((g->flags & SF_SHOWLOG) != 0) {
|
if ((g->flags & SF_SHOWLOG) != 0) {
|
||||||
s->scale_log = 1;
|
s->scale_log = 1;
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#define TEMPGRAD "-t"
|
#define TEMPGRAD "-t"
|
||||||
#define INVERTX "-x"
|
#define INVERTX "-x"
|
||||||
#define INVERTY "-y"
|
#define INVERTY "-y"
|
||||||
|
#define MINHEIGHT "-m"
|
||||||
|
|
||||||
enum class text_node_t : uint32_t {
|
enum class text_node_t : uint32_t {
|
||||||
NONSPECIAL = 0,
|
NONSPECIAL = 0,
|
||||||
@ -85,6 +86,7 @@ struct special_node {
|
|||||||
char speedgraph;
|
char speedgraph;
|
||||||
char invertx;
|
char invertx;
|
||||||
char inverty;
|
char inverty;
|
||||||
|
int minheight;
|
||||||
struct special_node *next;
|
struct special_node *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user