Add parameter to specify a configuration file
This commit is contained in:
parent
31f1f99102
commit
618ebbeccc
1 changed files with 17 additions and 5 deletions
|
@ -147,6 +147,13 @@ class Config(util.store.Store):
|
||||||
parser = argparse.ArgumentParser(
|
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"
|
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(
|
parser.add_argument(
|
||||||
"-m", "--modules", nargs="+", action="append", default=[], help=MODULE_HELP
|
"-m", "--modules", nargs="+", action="append", default=[], help=MODULE_HELP
|
||||||
)
|
)
|
||||||
|
@ -203,13 +210,18 @@ class Config(util.store.Store):
|
||||||
|
|
||||||
self.__args = parser.parse_args(args)
|
self.__args = parser.parse_args(args)
|
||||||
|
|
||||||
for cfg in [
|
if self.__args.config_file:
|
||||||
"~/.bumblebee-status.conf",
|
cfg = self.__args.config_file
|
||||||
"~/.config/bumblebee-status.conf",
|
|
||||||
"~/.config/bumblebee-status/config",
|
|
||||||
]:
|
|
||||||
cfg = os.path.expanduser(cfg)
|
cfg = os.path.expanduser(cfg)
|
||||||
self.load_config(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]
|
parameters = [item for sub in self.__args.parameters for item in sub]
|
||||||
for param in parameters:
|
for param in parameters:
|
||||||
|
|
Loading…
Reference in a new issue