diff --git a/README.md b/README.md index a8bc13c..6ca0749 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,10 @@ optional arguments: ## Configuration file -pirate-get will check to see if `$HOME/.config/pirate-get/pirate.cfg` exists. If it does it will use it as its default configuration settings. +You can use a file to override pirate-get's default settings. pirate-get will +first check if `$XDG_CONFIG_HOME/pirate-get/pirate.cfg` exists, then check if +`$HOME/.config/pirate-get/pirate.cfg` exists, and load the first file it finds. + ### SaveToFile diff --git a/pirate-get.py b/pirate-get.py index fa0f02f..706d9da 100755 --- a/pirate-get.py +++ b/pirate-get.py @@ -80,7 +80,13 @@ def main(): config.set('SaveToFile', 'directory', '~/Dropbox/pirate-get/') # load user options, to override default ones - config.read([os.path.expanduser('~/.config/pirate-get/pirate.cfg')]) + def config_to_load(): + if os.path.isfile(os.path.expandvars('$XDG_CONFIG_HOME/pirate-get/pirate.cfg')): + return os.path.expandvars('$XDG_CONFIG_HOME/pirate-get/pirate.cfg') + else: + return os.path.expanduser('~/.config/pirate-get/pirate.cfg') + + config.read([config_to_load()]) parser = argparse.ArgumentParser(description='Finds and downloads torrents from the Pirate Bay') parser.add_argument('-b', dest='browse', action='store_true', help="Display in Browse mode", default=False)