How to use the py3status.formatter.expand_color function in py3status

To help you get started, we’ve selected a few py3status examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ultrabug / py3status / py3status / py3.py View on Github external
# colors are special we want to make sure that we treat a color
            # that was explicitly set to None as a True value.  Ones that are
            # not set should be treated as None
            if name.startswith("color_"):
                _name = name[6:].lower()
                # use color "hidden" to hide blocks
                if _name == "hidden":
                    param = "hidden"
                # TODO: removing this statement does not fail "test_color_10()" but would fail
                # easily in the bar. the test is there to raise awareness about this.
                # TODO: "test_color_11()" shows how the tests can be incorrect as it does not print
                # everything correctly (i.e. orange vs ORaNgE) due to non composite/formatter code.
                elif hasattr(param, "none_setting"):
                    # see if named color and use if it is
                    param = expand_color(_name)
                elif param is None:
                    param = self._none_color
            # if a non-color parameter and was not set then set to default
            elif hasattr(param, "none_setting"):
                param = default
            self._config_setting[name] = param
        return self._config_setting[name]
github ultrabug / py3status / py3status / py3.py View on Github external
def _get_color(self, color):
        if color:
            if color[0] == "#":
                return expand_color(color)
            return self._get_config_setting("color_" + color)
github ultrabug / py3status / py3status / core.py View on Github external
config = self.config["py3_config"]
        param = config[name].get(attribute, self.none_setting)
        if hasattr(param, "none_setting") and name in config[".module_groups"]:
            for module in config[".module_groups"][name]:
                if attribute in config.get(module, {}):
                    param = config[module].get(attribute)
                    break
        if hasattr(param, "none_setting"):
            # check py3status config section
            param = config["py3status"].get(attribute, self.none_setting)
        if hasattr(param, "none_setting"):
            # check py3status general section
            param = config["general"].get(attribute, self.none_setting)
        if param and (attribute == "color" or attribute.startswith("color_")):
            # check color value
            param = expand_color(param.lower(), self.none_setting)
        return param