diff --git a/startkde/startplasma.cpp b/startkde/startplasma.cpp --- a/startkde/startplasma.cpp +++ b/startkde/startplasma.cpp @@ -185,12 +185,20 @@ } sourceFiles(scripts); - // Make sure that the KDE prefix is first in XDG_DATA_DIRS and that it's set at all. - // The spec allows XDG_DATA_DIRS to be not set, but X session startup scripts tend - // to set it to a list of paths *not* including the KDE prefix if it's not /usr or - // /usr/local. - if (!qEnvironmentVariableIsSet("XDG_DATA_DIRS")) { - qputenv("XDG_DATA_DIRS", KDE_INSTALL_FULL_DATAROOTDIR ":/usr/share:/usr/local/share"); + // To ensure the proper resources are available, the data root dir + // needs to be available in the XDG_DATA_DIRS variable, with + // the right preference. + QString xdgDataDirsValue; + if (qEnvironmentVariableIsSet("XDG_DATA_DIRS")) { + xdgDataDirsValue = QString::fromLocal8Bit(qgetenv("XDG_DATA_DIRS")); + } else { + xdgDataDirsValue = QLatin1String("/usr/local/share:/usr/share"); + } + const QString kdeInstallFullDataRootDir = QStringLiteral(KDE_INSTALL_FULL_DATAROOTDIR); + QVector xdgDataDirs = xdgDataDirsValue.splitRef(QLatin1Char(':')); + if (!xdgDataDirs.contains(QStringRef(&kdeInstallFullDataRootDir))) { + QString xdgDataDirsNewValue = kdeInstallFullDataRootDir + QLatin1Char(':') + xdgDataDirsValue; + qputenv("XDG_DATA_DIRS", xdgDataDirsNewValue.toLocal8Bit()); } }