--- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -788,6 +788,10 @@ const char *BLI_getDefaultDocumentFolder(void) { #if !defined(WIN32) + const char *xdg_documents_dir = getenv("XDG_DOCUMENTS_DIR"); + if (xdg_documents_dir) + return xdg_documents_dir; + return getenv("HOME"); #else /* Windows */ @@ -1765,7 +1769,14 @@ } } #else - /* Other OS's - Try TMP and TMPDIR */ + /* Other OS's - Try XDG_CACHE_HOME, TMP and TMPDIR */ + if (fullname[0] == '\0') { + const char *tmp = getenv("XDG_CACHE_HOME"); + if (tmp && BLI_is_dir(tmp)) { + BLI_strncpy(fullname, tmp, maxlen); + } + } + if (fullname[0] == '\0') { const char *tmp = getenv("TMP"); if (tmp && BLI_is_dir(tmp)) { @@ -1782,7 +1793,10 @@ #endif if (fullname[0] == '\0') { - BLI_strncpy(fullname, "/tmp/", maxlen); + /* use $HOME/.cache/ as fallback */ + const char *home = getenv("HOME"); + BLI_strncpy(fullname, home, maxlen); + strncat(fullname,"/.cache/",8); } else { /* add a trailing slash if needed */ BLI_add_slash(fullname);