From 618ebbecccd03df95dfe62b053adc130387341b9 Mon Sep 17 00:00:00 2001 From: Michal Cieslicki Date: Sat, 20 Feb 2021 13:50:31 +0100 Subject: [PATCH] Add parameter to specify a configuration file --- bumblebee_status/core/config.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/bumblebee_status/core/config.py b/bumblebee_status/core/config.py index b777e6d..b5fd5ef 100644 --- a/bumblebee_status/core/config.py +++ b/bumblebee_status/core/config.py @@ -147,6 +147,13 @@ class Config(util.store.Store): parser = argparse.ArgumentParser( description="bumblebee-status is a modular, theme-able status line generator for the i3 window manager. https://github.com/tobi-wan-kenobi/bumblebee-status/wiki" ) + parser.add_argument( + "-c", + "--config-file", + action="store", + default=None, + help="Specify a configuration file to use" + ) parser.add_argument( "-m", "--modules", nargs="+", action="append", default=[], help=MODULE_HELP ) @@ -203,13 +210,18 @@ class Config(util.store.Store): self.__args = parser.parse_args(args) - for cfg in [ - "~/.bumblebee-status.conf", - "~/.config/bumblebee-status.conf", - "~/.config/bumblebee-status/config", - ]: + if self.__args.config_file: + cfg = self.__args.config_file cfg = os.path.expanduser(cfg) self.load_config(cfg) + else: + for cfg in [ + "~/.bumblebee-status.conf", + "~/.config/bumblebee-status.conf", + "~/.config/bumblebee-status/config", + ]: + cfg = os.path.expanduser(cfg) + self.load_config(cfg) parameters = [item for sub in self.__args.parameters for item in sub] for param in parameters: