From e770869514d7162f17951b2bdd11c278d7e6ff2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=B6ster?= Date: Wed, 7 Dec 2016 17:45:40 +0100 Subject: [PATCH 1/3] Add configuration for graph direction --- i3pystatus/cpu_usage_graph.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/i3pystatus/cpu_usage_graph.py b/i3pystatus/cpu_usage_graph.py index ec3f2bc..a9fa259 100644 --- a/i3pystatus/cpu_usage_graph.py +++ b/i3pystatus/cpu_usage_graph.py @@ -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 ('lr', 'rl')"), ) graph_width = 15 graph_style = 'blocks' format = '{cpu_graph}' cpu = 'usage_cpu' + direction = 'lr' def init(self): super().init() @@ -47,6 +49,10 @@ class CpuUsageGraph(CpuUsage, ColorRangeModule): 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 is "rl": + graph = graph[::-1] + format_options.update({'cpu_graph': graph}) color = self.get_gradient(core_reading, self.colors) From 1e501fc60bd0688e3df8a42564c71b1a54eec011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=B6ster?= Date: Wed, 7 Dec 2016 18:02:29 +0100 Subject: [PATCH 2/3] Fix wrongly placed whitespace --- i3pystatus/cpu_usage_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i3pystatus/cpu_usage_graph.py b/i3pystatus/cpu_usage_graph.py index a9fa259..55cd62e 100644 --- a/i3pystatus/cpu_usage_graph.py +++ b/i3pystatus/cpu_usage_graph.py @@ -27,7 +27,7 @@ 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 ('lr', 'rl')"), + ("direction", "Graph running direction ('lr', 'rl')"), ) graph_width = 15 From e91e193b22c36065a7d3e16254f869f00e5b4b84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20K=C3=B6ster?= Date: Thu, 8 Dec 2016 11:50:09 +0100 Subject: [PATCH 3/3] Improve naming and add verification --- i3pystatus/cpu_usage_graph.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/i3pystatus/cpu_usage_graph.py b/i3pystatus/cpu_usage_graph.py index 55cd62e..838ffa9 100644 --- a/i3pystatus/cpu_usage_graph.py +++ b/i3pystatus/cpu_usage_graph.py @@ -27,14 +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 ('lr', 'rl')"), + ("direction", "Graph running direction ('left-to-right', 'right-to-left')"), ) graph_width = 15 graph_style = 'blocks' format = '{cpu_graph}' cpu = 'usage_cpu' - direction = 'lr' + direction = 'left-to-right' def init(self): super().init() @@ -50,8 +50,12 @@ class CpuUsageGraph(CpuUsage, ColorRangeModule): graph = make_graph(self.cpu_readings, 0.0, 100.0, self.graph_style) - if self.direction is "rl": + 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})