summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2021-04-28 15:45:37 +1000
committerMiguel Jacq <mig@mig5.net>2021-04-28 15:45:37 +1000
commitfe64d40e45941a3c8668f36788b73fd27f3d4a75 (patch)
treeaf2f8f9116b0e3d9c5e9bd968b3afc8f7ec03d49
parent470fb2bda3a04c856256191ceee267ce94515eef (diff)
downloadonionshare-fe64d40e45941a3c8668f36788b73fd27f3d4a75.tar.gz
onionshare-fe64d40e45941a3c8668f36788b73fd27f3d4a75.zip
Use XDG_CONFIG_HOME environment variable if it is present, otherwise fall back to ~/.config
-rw-r--r--cli/onionshare_cli/common.py12
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):