diff --git a/src/core/utilities.cpp b/src/core/utilities.cpp
index c6996d5df..101638a17 100644
--- a/src/core/utilities.cpp
+++ b/src/core/utilities.cpp
@@ -15,27 +15,32 @@
along with Clementine. If not, see .
*/
-#include "timeconstants.h"
#include "utilities.h"
-#include "core/logging.h"
-#include "sha2.h"
+#include
+
+#include
#include
#include
#include
#include
#include
+#include
#include
#include
#include
+#include
#include
+#include
#include
#include
#include
-#include
-#include
-#include
+
+#include "core/logging.h"
+#include "timeconstants.h"
+
+#include "sha2.h"
#if defined(Q_OS_UNIX)
# include
@@ -59,8 +64,6 @@
# include "IOKit/ps/IOPSKeys.h"
#endif
-#include
-
namespace Utilities {
static QString tr(const char* str) {
@@ -290,14 +293,28 @@ QString GetConfigPath(ConfigPath config) {
}
break;
+ case Path_CacheRoot: {
+ #if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
+ char* xdg = getenv("XDG_CACHE_HOME");
+ if (!xdg || !*xdg) {
+ return QString("%1/.cache/%2").arg(QDir::homePath(), QCoreApplication::organizationName());
+ } else {
+ return QString("%1/%2").arg(xdg, QCoreApplication::organizationName());
+ }
+ #else
+ return GetConfigPath(Path_Root);
+ #endif
+ }
+ break;
+
case Path_AlbumCovers:
return GetConfigPath(Path_Root) + "/albumcovers";
case Path_NetworkCache:
- return GetConfigPath(Path_Root) + "/networkcache";
-
+ return GetConfigPath(Path_CacheRoot) + "/networkcache";
+
case Path_MoodbarCache:
- return GetConfigPath(Path_Root) + "/moodbarcache";
+ return GetConfigPath(Path_CacheRoot) + "/moodbarcache";
case Path_GstreamerRegistry:
return GetConfigPath(Path_Root) +
diff --git a/src/core/utilities.h b/src/core/utilities.h
index 93bdd8962..225842962 100644
--- a/src/core/utilities.h
+++ b/src/core/utilities.h
@@ -110,6 +110,7 @@ namespace Utilities {
Path_DefaultMusicLibrary,
Path_LocalSpotifyBlob,
Path_MoodbarCache,
+ Path_CacheRoot,
};
QString GetConfigPath(ConfigPath config);