提交 7208bd3d 编写于 作者: N nicolargo

[Feature Request] Option in config to change character used to display...

[Feature Request] Option in config to change character used to display percentage in Quicklook #1511
上级 2ec1adb1
......@@ -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
......
......@@ -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:
......
......@@ -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.
......
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册