diff --git a/conf/glances.conf b/conf/glances.conf index 1e985bf7d9d899d77193c2d87f0918f2cadd9c69..b8a6e96105e4447f4d43c9ceae5a038fb1bff7a6 100644 --- a/conf/glances.conf +++ b/conf/glances.conf @@ -27,6 +27,8 @@ max_processes_display=30 # Set to true to disable a plugin # Note: you can also disable it from the command line (see --disable-plugin) disable=false +# Graphical percentage char used in the terminal user interface (default is |) +percentage_char=| # Define CPU, MEM and SWAP thresholds in % cpu_careful=50 cpu_warning=70 diff --git a/glances/outputs/glances_bars.py b/glances/outputs/glances_bars.py index 9d4b916a66db9d7e7eea9160d8d9fd257596bcb2..fda2039f74ec9053851d6bf0f1c8b773ea74ba6e 100644 --- a/glances/outputs/glances_bars.py +++ b/glances/outputs/glances_bars.py @@ -23,8 +23,6 @@ from __future__ import division from math import modf -curses_bars = [' ', ' ', ' ', ' ', '|', '|', '|', '|', '|'] - class Bar(object): @@ -40,7 +38,12 @@ class Bar(object): sys.stdout.flush() """ - def __init__(self, size, pre_char='[', post_char=']', empty_char=' ', with_text=True): + def __init__(self, size, + percentage_char='|', empty_char=' ', + pre_char='[', post_char=']', + with_text=True): + # Build curses_bars + self.__curses_bars = [empty_char] * 5 + [percentage_char] * 5 # Bar size self.__size = size # Bar current percent @@ -85,9 +88,9 @@ class Bar(object): def get(self): """Return the bars.""" frac, whole = modf(self.size * self.percent / 100.0) - ret = curses_bars[8] * int(whole) + ret = self.__curses_bars[8] * int(whole) if frac > 0: - ret += curses_bars[int(frac * 8)] + ret += self.__curses_bars[int(frac * 8)] whole += 1 ret += self.__empty_char * int(self.size - whole) if self.__with_text: diff --git a/glances/plugins/glances_plugin.py b/glances/plugins/glances_plugin.py index 482fca63fb2e92329cdbe343efc61967c07a7d1c..755a300dff6311c7c82059dd3c713dca234edf5a 100644 --- a/glances/plugins/glances_plugin.py +++ b/glances/plugins/glances_plugin.py @@ -726,7 +726,7 @@ class GlancesPlugin(object): # Return the action list return log_tag[0].lower() == 'true' - def get_conf_value(self, value, header="", plugin_name=None): + def get_conf_value(self, value, header="", plugin_name=None, default=[]): """Return the configuration (header_) value for the current plugin. ...or the one given by the plugin_name var. @@ -742,7 +742,7 @@ class GlancesPlugin(object): try: return self._limits[plugin_name + '_' + value] except KeyError: - return [] + return default def is_hide(self, value, header=""): """Return True if the value is in the hide configuration list. diff --git a/glances/plugins/glances_quicklook.py b/glances/plugins/glances_quicklook.py index ebafaf4fad8e55d76f1930cb7209816dcad027a5..32ec62e8c48e87622f34f0284f6eaabba6bdcf8a 100644 --- a/glances/plugins/glances_quicklook.py +++ b/glances/plugins/glances_quicklook.py @@ -129,7 +129,9 @@ class Plugin(GlancesPlugin): sparkline_tag = data.available if not sparkline_tag: # Fallback to bar if Sparkline module is not installed - data = Bar(max_width) + data = Bar(max_width, + percentage_char=self.get_conf_value('percentage_char', + default=['|'])[0]) # Build the string message if 'cpu_name' in self.stats and 'cpu_hz_current' in self.stats and 'cpu_hz' in self.stats: