chiark / gitweb /
Cope with lack of XDG config directories.
authorSimon Tatham <anakin@pobox.com>
Wed, 6 Dec 2023 07:34:22 +0000 (07:34 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 6 Dec 2023 07:35:17 +0000 (07:35 +0000)
If the host system is a pure server which you log into via ssh, it may
not have these at all. Hard-code the default ~/.config as a fallback.

login.py

index 279f28f9ba12e057c3747ac4fa7d1ca51beca942..8ed54eabc36c41928ab3a7dd2054ec99c81d0d9d 100644 (file)
--- a/login.py
+++ b/login.py
@@ -4,7 +4,11 @@ import os
 import xdg
 
 def config_dir():
-    return os.path.join(xdg.XDG_CONFIG_HOME, "mastodonochrome")
+    try:
+        config_home = xdg.XDG_CONFIG_HOME
+    except AttributeError:
+        config_home = os.path.join(os.environ["HOME"], ".config")
+    return os.path.join(config_home, "mastodonochrome")
 def config_file():
     return os.path.join(config_dir(), "auth")