From: Simon Tatham Date: Wed, 6 Dec 2023 07:34:22 +0000 (+0000) Subject: Cope with lack of XDG config directories. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d964711d81d1f1376132c6c6cf9ad55d174fab62;p=mastodonochrome.git Cope with lack of XDG config directories. 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. --- diff --git a/login.py b/login.py index 279f28f..8ed54ea 100644 --- 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")