Skip to content

Commit b17ccc3

Browse files
committed
prefer XDG_CONFIG_HOME on all platforms
convenient escape-hatch
1 parent acfaacb commit b17ccc3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

copyparty/__main__.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,21 @@ def get_unixdir() -> str:
228228
if E.mod.endswith("__init__"):
229229
E.mod = os.path.dirname(E.mod)
230230

231-
if sys.platform == "win32":
231+
try:
232+
p = os.environ.get("XDG_CONFIG_HOME")
233+
if not p:
234+
raise Exception()
235+
p = os.path.abspath(os.path.realpath(p))
236+
p = os.path.join(p, "copyparty")
237+
if not os.path.isdir(p):
238+
os.mkdir(p)
239+
os.listdir(p)
240+
except:
241+
p = ""
242+
243+
if p:
244+
E.cfg = p
245+
elif sys.platform == "win32":
232246
bdir = os.environ.get("APPDATA") or os.environ.get("TEMP") or "."
233247
E.cfg = os.path.normpath(bdir + "/copyparty")
234248
elif sys.platform == "darwin":

0 commit comments

Comments
 (0)