Skip to content

Make config file configurable #259

@mkoskar

Description

@mkoskar

Right now config file is hardcoded to be $XDG_CONFIG(~/.config if not defined)/afew/config. In usecases concerning multiple notmuch dbs this is preventing to have separate configuration per db.

I've solved it with following quick and dirty solution introducing AFEW_CONFIG environment variable:

diff --git a/afew/Settings.py b/afew/Settings.py
index 44d6f3c..b37154e 100644
--- a/afew/Settings.py
+++ b/afew/Settings.py
@@ -19,7 +19,7 @@ settings = ConfigParser()
 settings.optionxform = str
 
 settings.readfp(open(os.path.join(os.path.dirname(__file__), 'defaults', 'afew.config')))
-settings.read(os.path.join(user_config_dir, 'config'))
+settings.read(os.environ.get('AFEW_CONFIG', os.path.join(user_config_dir, 'config')))
 
 # All the values for keys listed here are interpreted as ;-delimited lists
 value_is_a_list = ['tags', 'tags_blacklist']

I guess it would be nicer if there were also accompanying argparse() parameter (probably -c). I haven't got around to do it myself mainly because it would need refactoring of Settings.py code which does parsing of settings on import.

If above is acceptable for now let me know and I'll make it as PR, probably mentioning it in man page would be good too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions