From 6bc5ebf889a3fbbf00e3b77b01b04cb06ec6787a Mon Sep 17 00:00:00 2001 From: Adam Hitchcock Date: Thu, 18 Jan 2024 17:00:35 -0800 Subject: [PATCH] support xdg config file standard --- mackup/config.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mackup/config.py b/mackup/config.py index 9ad9a36d1..c99dbd1ee 100644 --- a/mackup/config.py +++ b/mackup/config.py @@ -5,14 +5,11 @@ from .constants import ( CUSTOM_APPS_DIR, - MACKUP_BACKUP_PATH, - MACKUP_CONFIG_FILE, ENGINE_DROPBOX, ENGINE_GDRIVE, ENGINE_ICLOUD, ENGINE_FS, ) - from .utils import ( error, get_dropbox_folder_location, @@ -143,7 +140,17 @@ def _setup_parser(self, filename=None): # If we are not overriding the config filename if not filename: - filename = MACKUP_CONFIG_FILE + if os.path.exists(MACKUP_CONFIG_FILE): + filename = MACKUP_CONFIG_FILE + elif "MACKUP_CONFIG_FILE" in os.environ: + filename = os.environ["MACKUP_CONFIG_FILE"] + elif "XDG_CONFIG_HOME" in os.environ: + filename = os.path.join( + os.environ["XDG_CONFIG_HOME"], + MACKUP_CONFIG_FILE.lstrip("."), + ) + else: + filename = MACKUP_CONFIG_FILE parser = configparser.ConfigParser( allow_no_value=True, inline_comment_prefixes=(";", "#")