Skip to content

Commit

Permalink
Merge pull request #35 from mankoell/xdg_dir_config
Browse files Browse the repository at this point in the history
look for config files in xdg directory
  • Loading branch information
novoid committed Mar 20, 2017
2 parents bb63713 + 8cf55e6 commit 3993dd7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions memacs/lib/argparser.py
Expand Up @@ -125,7 +125,7 @@ def __add_arguments(self):
# ---------------------
# Config parser
# ---------------------
if self.__use_config_parser_name != "":
if self.__use_config_parser_name:
self.add_argument("-c", "--config",
dest="configfile",
help="path to config file",
Expand Down Expand Up @@ -168,7 +168,16 @@ def parse_args(self, args=None, namespace=None):
# ---------------------
# Config parser
# ---------------------
if self.__use_config_parser_name != "":
if self.__use_config_parser_name:
xdg = os.getenv('XDG_CONFIG_HOME', os.path.expanduser('~/.config'))
configdir = os.path.join(xdg, 'memacs')

if os.path.isdir(configdir):
for filename in os.listdir(configdir):
if self.__use_config_parser_name == os.path.splitext(filename)[0]:
args.configfile = os.path.join(configdir, filename)
continue

if args.configfile:
if not os.path.exists(args.configfile):
self.error("Config file (%s) does not exist" %
Expand Down

0 comments on commit 3993dd7

Please sign in to comment.