diff options
author | Von Random <von@vdrandom.org> | 2017-01-13 14:00:37 +0300 |
---|---|---|
committer | Von Random <von@vdrandom.org> | 2017-01-13 14:00:37 +0300 |
commit | 4834c25da42d6b90528d0ab5388fcf466f0d5baf (patch) | |
tree | c1141bf4950547f5784a8bee73dbfa8d6f5f6c20 | |
parent | 31ece2995a5ece873aeff5bea17642480c1aa9ca (diff) |
add hide_ok option support both globally (precedence) and per plugin, true by default
-rw-r--r-- | conf.ini | 2 | ||||
-rw-r--r-- | plugins/__init__.py | 1 | ||||
-rw-r--r-- | plugins/load.py | 3 | ||||
-rwxr-xr-x | vdstatus | 5 |
4 files changed, 6 insertions, 5 deletions
@@ -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 diff --git a/plugins/__init__.py b/plugins/__init__.py index b747e38..734c684 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -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') diff --git a/plugins/load.py b/plugins/load.py index 2da84e2..41c29e7 100644 --- a/plugins/load.py +++ b/plugins/load.py @@ -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) @@ -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) |