From 896827734f4abe043aeb6f221e18a56677bd4300 Mon Sep 17 00:00:00 2001 From: Pedro Maltez Date: Tue, 11 Nov 2014 08:05:05 +0000 Subject: [PATCH] Respect XDG_CONFIG_HOME if it is set --- pirate-get.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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)