Skip to content

Commit

Permalink
Merge pull request enkore#503 from nkoester/feat__cpu_usage_graph_dir…
Browse files Browse the repository at this point in the history
…ection

Add configuration for graph direction
  • Loading branch information
enkore committed Jan 11, 2017
2 parents dd2d940 + e91e193 commit 90cc53d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions i3pystatus/cpu_usage_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class CpuUsageGraph(CpuUsage, ColorRangeModule):
("end_color", "Hex or English name for end of color range, eg '#FF0000' or 'red'"),
("graph_width", "Width of the cpu usage graph"),
("graph_style", "Graph style ('blocks', 'braille-fill', 'braille-peak', or 'braille-snake')"),
("direction", "Graph running direction ('left-to-right', 'right-to-left')"),
)

graph_width = 15
graph_style = 'blocks'
format = '{cpu_graph}'
cpu = 'usage_cpu'
direction = 'left-to-right'

def init(self):
super().init()
Expand All @@ -47,6 +49,14 @@ def run(self):
self.cpu_readings = self.cpu_readings[:self.graph_width]

graph = make_graph(self.cpu_readings, 0.0, 100.0, self.graph_style)

if self.direction == "right-to-left":
graph = graph[::-1]
elif self.direction == "left-to-right":
pass
else:
raise Exception("Invalid direction '%s'." % self.direction)

format_options.update({'cpu_graph': graph})

color = self.get_gradient(core_reading, self.colors)
Expand Down

0 comments on commit 90cc53d

Please sign in to comment.