37
37
38
38
std::string cpu_string ( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigned int graph_lines,
39
39
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 )
41
41
{
42
42
43
43
float percentage;
@@ -80,7 +80,13 @@ std::string cpu_string( CPU_MODE cpu_mode, unsigned int cpu_usage_delay, unsigne
80
80
}
81
81
}
82
82
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 )
84
90
{
85
91
oss << " [" ;
86
92
oss << get_graph_by_percentage ( unsigned ( percentage ), graph_lines );
@@ -123,6 +129,8 @@ void print_help()
123
129
<< " \t Use powerline left symbols throughout the output, enables --colors\n "
124
130
<< " -q, --powerline-right\n "
125
131
<< " \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 "
126
134
<< " -i <value>, --interval <value>\n "
127
135
<< " \t Set tmux status refresh interval in seconds. Default: 1 second\n "
128
136
<< " -g <value>, --graph-lines <value>\n "
@@ -144,6 +152,7 @@ int main( int argc, char** argv )
144
152
bool use_colors = false ;
145
153
bool use_powerline_left = false ;
146
154
bool use_powerline_right = false ;
155
+ bool use_vert_graph = false ;
147
156
MEMORY_MODE mem_mode = MEMORY_MODE_DEFAULT;
148
157
CPU_MODE cpu_mode = CPU_MODE_DEFAULT;
149
158
@@ -157,6 +166,7 @@ int main( int argc, char** argv )
157
166
{ " colors" , no_argument, NULL , ' c' },
158
167
{ " powerline-left" , no_argument, NULL , ' p' },
159
168
{ " powerline-right" , no_argument, NULL , ' q' },
169
+ { " vertical-graph" , no_argument, NULL , ' v' },
160
170
{ " interval" , required_argument, NULL , ' i' },
161
171
{ " graph-lines" , required_argument, NULL , ' g' },
162
172
{ " mem-mode" , required_argument, NULL , ' m' },
@@ -167,7 +177,7 @@ int main( int argc, char** argv )
167
177
168
178
int c;
169
179
// 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 )
171
181
{
172
182
switch ( c )
173
183
{
@@ -186,6 +196,9 @@ int main( int argc, char** argv )
186
196
use_colors = true ;
187
197
use_powerline_right = true ;
188
198
break ;
199
+ case ' v' : // --vertical-graph
200
+ use_vert_graph = true ;
201
+ break ;
189
202
case ' i' : // --interval, -i
190
203
if ( atoi ( optarg ) < 1 )
191
204
{
@@ -247,7 +260,7 @@ int main( int argc, char** argv )
247
260
MemoryStatus memory_status;
248
261
mem_status ( memory_status );
249
262
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 )
251
264
<< load_string ( use_colors, use_powerline_left, use_powerline_right, averages_count );
252
265
253
266
std::cout << std::endl;
0 commit comments