File indexing completed on 2024-04-21 03:56:50

0001 /*
0002     This file is part of KDE Frameworks
0003     SPDX-FileCopyrightText: 2018 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006 */
0007 
0008 #ifndef SETUP_XDG_DIRS_H
0009 #define SETUP_XDG_DIRS_H
0010 
0011 #include <QCoreApplication>
0012 #include <QFile>
0013 #include <QStandardPaths>
0014 
0015 static void setupXdgDirs()
0016 {
0017     // We need to keep the system XDG_DATA_DIRS to find mimetypes
0018     const QByteArray defaultDataDirs = qEnvironmentVariableIsSet("XDG_DATA_DIRS") ? qgetenv("XDG_DATA_DIRS") : QByteArray("/usr/local/share:/usr/share");
0019     const QByteArray modifiedDataDirs = QFile::encodeName(QCoreApplication::applicationDirPath()) + "/data:" + defaultDataDirs;
0020     qputenv("XDG_DATA_DIRS", modifiedDataDirs);
0021 
0022     // We don't need the system config dirs, we provide our own applications.menu
0023     const QByteArray modifiedConfigDirs = QFile::encodeName(QCoreApplication::applicationDirPath()) + "/data";
0024     qputenv("XDG_CONFIG_DIRS", modifiedConfigDirs);
0025 }
0026 
0027 #endif