diff options
author | Micah Lee <micah@micahflee.com> | 2021-04-29 01:25:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-29 01:25:03 +0000 |
commit | 66918946aefd5599976013dbba4a76dcccbac6ac (patch) | |
tree | 41d3fc2c0bb36244db00f201b03282ceacd51549 | |
parent | 650bf9312852bd75dbef594ed31fc410829b333d (diff) | |
parent | fe64d40e45941a3c8668f36788b73fd27f3d4a75 (diff) | |
download | onionshare-66918946aefd5599976013dbba4a76dcccbac6ac.tar.gz onionshare-66918946aefd5599976013dbba4a76dcccbac6ac.zip |
Merge pull request #1336 from mig5/1293_support_xdg_config_home_env_var
Use XDG_CONFIG_HOME environment variable if it is present, otherwise fall back to ~/.config
-rw-r--r-- | cli/onionshare_cli/common.py | 12 |
1 files 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): |