afewmail / afew

an initial tagging script for notmuch mail
ISC License
325 stars 98 forks source link

Make config file configurable #259

Open mkoskar opened 4 years ago

mkoskar commented 4 years ago

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.

Madic- commented 3 years ago

Is a configurable config file still considered?

GuillaumeSeren commented 3 years ago

Hey, I don't think there is a PR around this one, someone should open one :rocket:

Vinfall commented 1 year ago

There is #307 hanging for a year now, any update or possibility to merge that? I don't see why it has no reply yet all other open PRs have some sort of review.