From fe64d40e45941a3c8668f36788b73fd27f3d4a75 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Wed, 28 Apr 2021 15:45:37 +1000 Subject: Use XDG_CONFIG_HOME environment variable if it is present, otherwise fall back to ~/.config --- cli/onionshare_cli/common.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cli/onionshare_cli/common.py b/cli/onionshare_cli/common.py index e812aa98..072babd1 100644 --- a/cli/onionshare_cli/common.py +++ b/cli/onionshare_cli/common.py @@ -133,13 +133,21 @@ class Common: except: # If for some reason we don't have the 'APPDATA' environment variable # (like running tests in Linux while pretending to be in Windows) - onionshare_data_dir = os.path.expanduser("~/.config/onionshare") + try: + xdg_config_home = os.environ["XDG_CONFIG_HOME"] + onionshare_data_dir = f"{xdg_config_home}/onionshare" + except: + onionshare_data_dir = os.path.expanduser("~/.config/onionshare") elif self.platform == "Darwin": onionshare_data_dir = os.path.expanduser( "~/Library/Application Support/OnionShare" ) else: - onionshare_data_dir = os.path.expanduser("~/.config/onionshare") + try: + xdg_config_home = os.environ["XDG_CONFIG_HOME"] + onionshare_data_dir = f"{xdg_config_home}/onionshare" + except: + onionshare_data_dir = os.path.expanduser("~/.config/onionshare") # Modify the data dir if running tests if getattr(sys, "onionshare_test_mode", False): -- cgit v1.2.3-54-g00ecf