add hide_ok option support both globally (precedence) and per plugin, true by default
This commit is contained in:
parent
31ece2995a
commit
4834c25da4
4 changed files with 6 additions and 5 deletions
2
conf.ini
2
conf.ini
|
@ -5,7 +5,7 @@ format = i3
|
|||
plugin = ping
|
||||
hosts = de-ber-as20647.anchors.atlas.ripe.net,nl-ams-as1101.anchors.atlas.ripe.net,uk-boh-as196745.anchors.atlas.ripe.net
|
||||
title = NET
|
||||
hide_ok = true
|
||||
hide_ok = false
|
||||
|
||||
[memory]
|
||||
plugin = mem
|
||||
|
|
|
@ -10,6 +10,7 @@ class PluginThreadCommon:
|
|||
self.thread.daemon = True
|
||||
self.freq = config.getint(section, 'freq', fallback=1)
|
||||
self.problem_value = config.getint(section, 'problem', fallback=70)
|
||||
self.hide_ok = config.getboolean(section, 'hide_ok', fallback=True)
|
||||
if config.has_option(section, 'color'):
|
||||
self.status['color'] = config.get(section, 'color')
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import plugins
|
|||
class PluginThread(plugins.PluginThreadCommon):
|
||||
def __init__(self, section, config):
|
||||
super(PluginThread, self).__init__(section, config)
|
||||
self.hide_ok = config.getboolean(section, 'hide_ok', fallback=False)
|
||||
|
||||
def main(self):
|
||||
loads = os.getloadavg()
|
||||
|
@ -13,7 +12,7 @@ class PluginThread(plugins.PluginThreadCommon):
|
|||
self.hide = False
|
||||
self.status['urgent'] = True
|
||||
else:
|
||||
self.hide = self.hide_ok
|
||||
self.hide = True
|
||||
self.status['urgent'] = False
|
||||
loads = [str(i) for i in loads]
|
||||
self.status['full_text'] = 'LA: ' + ' '.join(loads)
|
||||
|
|
5
vdstatus
5
vdstatus
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python3
|
||||
# TODO: handle SIGINT properly
|
||||
# TODO: consider per plugin hide_ok overriding global, not the other way around
|
||||
# TODO: add documentation / comments
|
||||
# TODO: interactivity support
|
||||
import argparse
|
||||
|
@ -30,6 +30,7 @@ class PluginRunner:
|
|||
self.config.read(config_file)
|
||||
self.output_format = self.config.get('main', 'format', fallback='term')
|
||||
self.output_freq = self.config.getint('main', 'output_freq', fallback=1)
|
||||
self.hide_ok = self.config.getboolean('main', 'hide_ok', fallback=True)
|
||||
self.plugins_loaded = list()
|
||||
self.config.remove_section('main')
|
||||
self.format_output = self.format_term
|
||||
|
@ -49,7 +50,7 @@ class PluginRunner:
|
|||
def query(self):
|
||||
outputs = list()
|
||||
for plugin in self.plugins_loaded:
|
||||
if not plugin.hide:
|
||||
if not self.hide_ok or not plugin.hide_ok or not plugin.hide:
|
||||
outputs.append(plugin.status)
|
||||
print(self.format_output(outputs), flush=True)
|
||||
|
||||
|
|
Loading…
Reference in a new issue