From beca26c2bf4676c6095abdb3551aa75abdbd6ad2 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sun, 17 Jan 2021 15:21:40 +0100 Subject: [PATCH] [core/config] Allow modules to be hidden when in critical/error state When a module is in critical state, the user can now hide the module (e.g. if pulseaudio fails to load). fixes #746 --- bumblebee_status/core/config.py | 20 +++++++++++++++++--- bumblebee_status/core/output.py | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/bumblebee_status/core/config.py b/bumblebee_status/core/config.py index c84d10c..b777e6d 100644 --- a/bumblebee_status/core/config.py +++ b/bumblebee_status/core/config.py @@ -172,6 +172,13 @@ class Config(util.store.Store): default=[], help="Specify a list of modules to hide when not in warning/error state", ) + parser.add_argument( + "-e", + "--errorhide", + nargs="+", + default=[], + help="Specify a list of modules that are hidden when in state error" + ) parser.add_argument( "-d", "--debug", action="store_true", help="Add debug fields to i3 output" ) @@ -302,14 +309,21 @@ class Config(util.store.Store): def iconset(self): return self.__args.iconset - """Returns which modules should be hidden if their state is not warning/critical + """Returns whether a module should be hidden if their state is not warning/critical - :return: list of modules to hide automatically - :rtype: list of strings + :return: True if module should be hidden automatically, False otherwise + :rtype: bool """ def autohide(self, name): return name in self.__args.autohide + """Returns which modules should be hidden if they are in state error + + :return: returns True if name should be hidden, False otherwise + :rtype: bool + """ + def errorhide(self, name): + return name in self.__args.errorhide # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 diff --git a/bumblebee_status/core/output.py b/bumblebee_status/core/output.py index 687cafd..e3ec476 100644 --- a/bumblebee_status/core/output.py +++ b/bumblebee_status/core/output.py @@ -216,6 +216,8 @@ class i3(object): continue if module.hidden(): continue + if "critical" in widget.state() and self.__config.errorhide(widget.module.name): + continue blocks.extend(self.separator_block(module, widget)) blocks.append(self.__content_block(module, widget)) core.event.trigger("next-widget")