summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils')
-rwxr-xr-xlib/utils/paths.py4
-rw-r--r--lib/utils/settings.py6
2 files changed, 7 insertions, 3 deletions
diff --git a/lib/utils/paths.py b/lib/utils/paths.py
index 3bc12c2a..542a0f2d 100755
--- a/lib/utils/paths.py
+++ b/lib/utils/paths.py
@@ -41,12 +41,12 @@ def get_resource_dir(name):
return realpath(os.path.join(dirname(realpath(__file__)), '..', '..', name))
-def get_user_dir(name=None):
+def get_user_dir(name=None, create=True):
try:
path = platformdirs.user_config_dir('inkstitch')
except ImportError:
path = os.path.expanduser('~/.inkstitch')
- if not os.path.exists(path):
+ if create and not os.path.exists(path):
os.makedirs(path)
if name is not None:
diff --git a/lib/utils/settings.py b/lib/utils/settings.py
index 42e6b233..28c52290 100644
--- a/lib/utils/settings.py
+++ b/lib/utils/settings.py
@@ -45,7 +45,11 @@ DEFAULT_SETTINGS = {
class GlobalSettings(MutableMapping):
def __init__(self):
super().__init__()
- self.__settings_file = os.path.join(get_user_dir(), "settings.json")
+ # We set create=False here because this code is executed on module load
+ # and via imports also runs on generate-inx-files, which with the Nix
+ # package manager is executed with a non-writable home directory.
+ user_dir = get_user_dir(create=False)
+ self.__settings_file = os.path.join(user_dir, "settings.json")
self.__settings = {}
for name, value in DEFAULT_METADATA.items():