Respect XDG base dir spec for config file

pull/350/head
Bao Trinh 2021-09-08 06:51:37 -05:00
parent 900557ecb1
commit 298bbc0fe8
No known key found for this signature in database
GPG Key ID: A9B3110B4EA55E36
1 changed files with 7 additions and 1 deletions

View File

@ -241,7 +241,13 @@ update_check=$update_check
log_level=$log_level log_level=$log_level
''') ''')
CONFIG_DIR: str = f'{os.path.expanduser("~")}/.config/bpytop'
def get_config_dir():
config_home = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
return os.path.join(config_home, 'bpytop')
CONFIG_DIR: str = get_config_dir()
if not os.path.isdir(CONFIG_DIR): if not os.path.isdir(CONFIG_DIR):
try: try:
os.makedirs(CONFIG_DIR) os.makedirs(CONFIG_DIR)