3737
3838std::string cpu_string ( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigned int graph_lines,
3939 bool use_colors = false ,
40- bool use_powerline_left = false , bool use_powerline_right = false )
40+ bool use_powerline_left = false , bool use_powerline_right = false , bool use_vert_graph = false )
4141{
4242
4343 float percentage;
@@ -80,7 +80,13 @@ std::string cpu_string( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigne
8080 }
8181 }
8282
83- if ( graph_lines > 0 )
83+ if ( use_vert_graph )
84+ {
85+ oss << " ▕" ;
86+ oss << get_graph_vert ( unsigned ( percentage ) );
87+ oss << " ▏" ;
88+ }
89+ else if ( graph_lines > 0 )
8490 {
8591 oss << " [" ;
8692 oss << get_graph_by_percentage ( unsigned ( percentage ), graph_lines );
@@ -123,6 +129,8 @@ void print_help()
123129 << " \t Use powerline left symbols throughout the output, enables --colors\n "
124130 << " -q, --powerline-right\n "
125131 << " \t Use powerline right symbols throughout the output, enables --colors\n "
132+ << " -v, --vertical-graph\n "
133+ << " \t Use vertical bar chart for CPU graph\n "
126134 << " -i <value>, --interval <value>\n "
127135 << " \t Set tmux status refresh interval in seconds. Default: 1 second\n "
128136 << " -g <value>, --graph-lines <value>\n "
@@ -144,6 +152,7 @@ int main( int argc, char** argv )
144152 bool use_colors = false ;
145153 bool use_powerline_left = false ;
146154 bool use_powerline_right = false ;
155+ bool use_vert_graph = false ;
147156 MEMORY_MODE mem_mode = MEMORY_MODE_DEFAULT;
148157 CPU_MODE cpu_mode = CPU_MODE_DEFAULT;
149158
@@ -157,6 +166,7 @@ int main( int argc, char** argv )
157166 { " colors" , no_argument, NULL , ' c' },
158167 { " powerline-left" , no_argument, NULL , ' p' },
159168 { " powerline-right" , no_argument, NULL , ' q' },
169+ { " vertical-graph" , no_argument, NULL , ' v' },
160170 { " interval" , required_argument, NULL , ' i' },
161171 { " graph-lines" , required_argument, NULL , ' g' },
162172 { " mem-mode" , required_argument, NULL , ' m' },
@@ -167,7 +177,7 @@ int main( int argc, char** argv )
167177
168178 int c;
169179 // while c != -1
170- while ( (c = getopt_long ( argc, argv, " hi:cpqg :m:a:t:" , long_options, NULL ) ) != -1 )
180+ while ( (c = getopt_long ( argc, argv, " hi:cpqvg :m:a:t:" , long_options, NULL ) ) != -1 )
171181 {
172182 switch ( c )
173183 {
@@ -186,6 +196,9 @@ int main( int argc, char** argv )
186196 use_colors = true ;
187197 use_powerline_right = true ;
188198 break ;
199+ case ' v' : // --vertical-graph
200+ use_vert_graph = true ;
201+ break ;
189202 case ' i' : // --interval, -i
190203 if ( atoi ( optarg ) < 1 )
191204 {
@@ -247,7 +260,7 @@ int main( int argc, char** argv )
247260 MemoryStatus memory_status;
248261 mem_status ( memory_status );
249262 std::cout << mem_string ( memory_status, mem_mode, use_colors, use_powerline_left, use_powerline_right )
250- << cpu_string ( cpu_mode, cpu_usage_delay, graph_lines, use_colors, use_powerline_left, use_powerline_right )
263+ << cpu_string ( cpu_mode, cpu_usage_delay, graph_lines, use_colors, use_powerline_left, use_powerline_right, use_vert_graph )
251264 << load_string ( use_colors, use_powerline_left, use_powerline_right, averages_count );
252265
253266 std::cout << std::endl;
0 commit comments