Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented switch direction of graph in all 4 direction #1999

Merged
merged 4 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 51 additions & 12 deletions doc/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: apcupsd_model
desc: Prints the model of the UPS.
- name: apcupsd_name
Expand Down Expand Up @@ -328,7 +330,8 @@ values:
See $cpu for more info on SMP. Uses a 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).
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.
args:
- (cpuN)
- (height),(width)
Expand All @@ -337,6 +340,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: curl
desc: |-
Download data from URI using Curl at the specified interval.
Expand Down Expand Up @@ -389,7 +394,8 @@ values:
scale (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).
and see). The flag '-x' inverts the x axis and '-y' inverts the y axis
of the graph.
args:
- (device)
- (height),(width)
Expand All @@ -398,14 +404,17 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: diskiograph_read
desc: |-
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 -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).
particular graph value (try it and see). The flag '-x' inverts the x
axis and '-y' inverts the y axis of the graph.
args:
- (device)
- (height),(width)
Expand All @@ -414,14 +423,17 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: diskiograph_write
desc: |-
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 -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).
particular graph value (try it and see). The flag '-x' inverts the x
axis and '-y' inverts the y axis of the graph.
args:
- (device)
- (height),(width)
Expand All @@ -430,6 +442,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: distribution
desc: |-
The name of the distribution. It could be that some of the
Expand All @@ -456,7 +470,8 @@ values:
per second). Uses a logarithmic scale (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).
graph value (try it and see). The flag '-x' inverts the x axis and '-y'
inverts the y axis of the graph.
args:
- (netdev)
- (height),(width)
Expand All @@ -465,6 +480,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: draft_mails
desc: |-
Number of mails marked as draft in the specified mailbox or
Expand Down Expand Up @@ -535,7 +552,8 @@ values:
graph. The scale parameter defines the maximum value of the graph. Use the
-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
and default_graph_width config settings.
and default_graph_width config settings. The flag '-x' inverts the x axis
and '-y' inverts the y axis of the graph.

If you need to execute a command with spaces, you have a
couple options:
Expand All @@ -562,6 +580,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: execi
desc: |-
Same as exec, but with a specific interval in seconds. The
Expand Down Expand Up @@ -593,6 +613,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: execp
desc: |-
Executes a shell command and displays the output in conky.
Expand Down Expand Up @@ -1111,14 +1133,17 @@ values:
in hex, minus the #. Uses a 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).
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.
args:
- (height),(width)
- (gradient colour 1)
- (gradient colour 2)
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: lowercase
desc: Converts all letters into lowercase.
args:
Expand Down Expand Up @@ -1164,7 +1189,8 @@ values:
values change depending on the amplitude of a particular graph value
(try it and see). Conky puts 'conky_' in front of function_name to
prevent accidental calls to the wrong function unless you put you
place 'conky_' in front of it yourself.
place 'conky_' in front of it yourself. The flag '-x' inverts the
x axis and '-y' inverts the y axis of the graph.
args:
- function_name
- (height),(width)
Expand All @@ -1173,6 +1199,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: lua_parse
desc: |-
Executes a Lua function with given parameters as per $lua,
Expand Down Expand Up @@ -1232,14 +1260,17 @@ values:
Memory usage graph. Uses a 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).
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.
args:
- (height),(width)
- (gradient colour 1)
- (gradient colour 2)
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: meminactive
desc: Amount of inactive memory. FreeBSD only.
- name: memlaundry
Expand All @@ -1266,14 +1297,17 @@ values:
and cache. Uses a 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).
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.
args:
- (height),(width)
- (gradient colour 1)
- (gradient colour 2)
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: mixer
desc: |-
Prints the mixer value as reported by the OS. On Linux, this
Expand Down Expand Up @@ -1529,7 +1563,7 @@ values:
used as 0,1,2,3,..

For possible arguments see nvidia and nvidiabar. To learn more about the
-t -l and gradient color options, see execgraph.
-t -l -x -y and gradient color options, see execgraph.
args:
- argument
- (height),(width)
Expand All @@ -1538,6 +1572,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- GPU_ID
- name: offset
desc: Move text over by N pixels. See also $voffset.
Expand Down Expand Up @@ -2328,7 +2364,8 @@ values:
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).
(try it and see). The flag '-x' inverts the x axis and '-y'
inverts the y axis of the graph.
args:
- (netdev)
- (height),(width)
Expand All @@ -2337,6 +2374,8 @@ values:
- (scale)
- (-t)
- (-l)
- (-x)
- (-y)
- name: uptime
desc: Uptime.
- name: uptime_short
Expand Down
59 changes: 38 additions & 21 deletions src/conky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,35 @@ static inline void set_foreground_color(Colour c) {
for (auto output : display_outputs()) output->set_foreground_color(c);
}

static inline void draw_graph_bars(special_node *current, std::unique_ptr<Colour[]>& tmpcolour,
conky::vec2i& text_offset, int i, int &j, int w,
int colour_idx, int cur_x, int by, int h) {
if (current->colours_set) {
if (current->tempgrad != 0) {
set_foreground_color(tmpcolour[static_cast<int>(
static_cast<float>(w - 2) -
current->graph[j] * (w - 2) /
std::max(static_cast<float>(current->scale),
1.0F))]);
} else {
set_foreground_color(tmpcolour[colour_idx++]);
}
}
/* Handle the case where y axis is to be inverted */
int offsety1 = current->inverty ? by : by + h;
int offsety2 = current->inverty ? by + current->graph[j] * (h - 1) / current->scale
: round_to_positive_int(static_cast<double>(by) + h -
current->graph[j] * (h - 1) /
current->scale);
/* this is mugfugly, but it works */
if (display_output()) {
display_output()->draw_line(
text_offset.x() + cur_x + i + 1, text_offset.y() + offsety1,
text_offset.x() + cur_x + i + 1, text_offset.y() + offsety2);
}
++j;
}

static void draw_string(const char *s) {
int i;
int i2;
Expand Down Expand Up @@ -1293,29 +1322,17 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) {
delete factory;
}
colour_idx = 0;
for (i = w - 2; i > -1; i--) {
if (current->colours_set) {
if (current->tempgrad != 0) {
set_foreground_color(tmpcolour[static_cast<int>(
static_cast<float>(w - 2) -
current->graph[j] * (w - 2) /
std::max(static_cast<float>(current->scale),
1.0F))]);
} else {
set_foreground_color(tmpcolour[colour_idx++]);
}
if(current->invertx){
for (i = 0; i <= w - 2; i++) {
draw_graph_bars(current, tmpcolour, text_offset,
i, j, w, colour_idx, cur_x, by, h);
}
/* this is mugfugly, but it works */
if (display_output()) {
display_output()->draw_line(
text_offset.x() + cur_x + i + 1, text_offset.y() + by + h,
text_offset.x() + cur_x + i + 1,
text_offset.y() +
round_to_positive_int(static_cast<double>(by) + h -
current->graph[j] * (h - 1) /
current->scale));
}
else{
for (i = w - 2; i > -1; i--) {
draw_graph_bars(current, tmpcolour, text_offset,
i, j, w, colour_idx, cur_x, by, h);
}
++j;
}
}
if (h > cur_y_add && h > font_h) { cur_y_add = h; }
Expand Down
Loading
Loading