mirror of
https://github.com/paul-nameless/tg
synced 2024-11-22 11:53:08 +00:00
Fallback to default directories if XDG is not set
Signed-off-by: c4llv07e <kseandi@gmail.com>
This commit is contained in:
parent
6e58d6791c
commit
1eeeb288cf
1 changed files with 8 additions and 5 deletions
13
tg/config.py
13
tg/config.py
|
@ -14,13 +14,18 @@ _linux = "Linux"
|
|||
def expand_path(path):
|
||||
return os.path.expandvars(os.path.expanduser(path))
|
||||
|
||||
CONFIG_DIR = expand_path("$XDG_CONFIG_HOME/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("XD_GDATA_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 = expand_path("$XDG_CACHE_HOME/tg/")
|
||||
FILES_DIR = os.path.join(CACHE_HOME, "tg/")
|
||||
MAILCAP_FILE: Optional[str] = None
|
||||
|
||||
LOG_LEVEL = "INFO"
|
||||
LOG_PATH = expand_path("$XDG_DATA_HOME/tg/")
|
||||
LOG_PATH = expand_path(DATA_HOME + "/tg/")
|
||||
|
||||
API_ID = "559815"
|
||||
API_HASH = "fd121358f59d764c57c55871aa0807ca"
|
||||
|
@ -80,8 +85,6 @@ KEEP_MEDIA = 7
|
|||
|
||||
FILE_PICKER_CMD = "ranger --choosefile={file_path}"
|
||||
|
||||
DOWNLOAD_DIR = expand_path("$XDG_DOWNLOAD_DIR")
|
||||
|
||||
if os.path.isfile(CONFIG_FILE):
|
||||
config_params = runpy.run_path(CONFIG_FILE) # type: ignore
|
||||
for param, value in config_params.items():
|
||||
|
|
Loading…
Reference in a new issue