From 298bbc0fe8064b1b5cc37a9d36907d9cf1ff7867 Mon Sep 17 00:00:00 2001 From: Bao Trinh Date: Wed, 8 Sep 2021 06:51:37 -0500 Subject: [PATCH] Respect XDG base dir spec for config file --- bpytop.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bpytop.py b/bpytop.py index 55c99ad..9edc1a9 100755 --- a/bpytop.py +++ b/bpytop.py @@ -241,7 +241,13 @@ update_check=$update_check 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): try: os.makedirs(CONFIG_DIR)