diff --git a/tg/config.py b/tg/config.py index 4d02df1..e894f1f 100644 --- a/tg/config.py +++ b/tg/config.py @@ -11,14 +11,21 @@ _darwin = "Darwin" _linux = "Linux" +def expand_path(path): + return os.path.expandvars(os.path.expanduser(path)) -CONFIG_DIR = os.path.expanduser("~/.config/tg/") +CONFIG_HOME = expand_path(os.getenv("XDG_CONFIG_HOME", "~/.config")) +CACHE_HOME = expand_path(os.getenv("XDG_CACHE_HOME", "~/.cache")) +DATA_HOME = expand_path(os.getenv("XDG_DATA_HOME", "~/.local/share")) +DOWNLOAD_DIR = expand_path(os.getenv("XDG_DOWNLOAD_DIR", "~/Downloads")) + +CONFIG_DIR = os.path.join(CONFIG_HOME, "tg/") CONFIG_FILE = os.path.join(CONFIG_DIR, "conf.py") -FILES_DIR = os.path.expanduser("~/.cache/tg/") +FILES_DIR = os.path.join(CACHE_HOME, "tg/") MAILCAP_FILE: Optional[str] = None LOG_LEVEL = "INFO" -LOG_PATH = os.path.expanduser("~/.local/share/tg/") +LOG_PATH = expand_path(DATA_HOME + "/tg/") API_ID = "559815" API_HASH = "fd121358f59d764c57c55871aa0807ca" @@ -78,8 +85,6 @@ FILE_PICKER_CMD = "ranger --choosefile={file_path}" -DOWNLOAD_DIR = os.path.expanduser("~/Downloads/") - if os.path.isfile(CONFIG_FILE): config_params = runpy.run_path(CONFIG_FILE) # type: ignore for param, value in config_params.items():