diff options
Diffstat (limited to 'src/platformsupport/services/genericunix/qgenericunixservices.cpp')
-rw-r--r-- | src/platformsupport/services/genericunix/qgenericunixservices.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/platformsupport/services/genericunix/qgenericunixservices.cpp b/src/platformsupport/services/genericunix/qgenericunixservices.cpp index fedaa3a655..77ea0f1db8 100644 --- a/src/platformsupport/services/genericunix/qgenericunixservices.cpp +++ b/src/platformsupport/services/genericunix/qgenericunixservices.cpp @@ -54,16 +54,24 @@ enum { debug = 0 }; static inline QByteArray detectDesktopEnvironment() { - if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION")) - return QByteArray("KDE"); - // Check Unity first, whose older versions also have "GNOME_DESKTOP_SESSION_ID" set. const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP"); - if (xdgCurrentDesktop == "Unity") - return QByteArrayLiteral("UNITY"); - // GNOME_DESKTOP_SESSION_ID is deprecated for some reason, but still check it - if (qgetenv("DESKTOP_SESSION") == "gnome" || !qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID")) - return QByteArray("GNOME"); - return QByteArray("UNKNOWN"); + if (!xdgCurrentDesktop.isEmpty()) + return xdgCurrentDesktop.toUpper(); // KDE, GNOME, UNITY, LXDE, MATE, XFCE... + + // Classic fallbacks + if (!qEnvironmentVariableIsEmpty("KDE_FULL_SESSION")) + return QByteArrayLiteral("KDE"); + if (!qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID")) + return QByteArrayLiteral("GNOME"); + + // Fallback to checking $DESKTOP_SESSION (unreliable) + const QByteArray desktopSession = qgetenv("DESKTOP_SESSION"); + if (desktopSession == "gnome") + return QByteArrayLiteral("GNOME"); + if (desktopSession == "xfce") + return QByteArrayLiteral("XFCE"); + + return QByteArrayLiteral("UNKNOWN"); } static inline bool checkExecutable(const QString &candidate, QString *result) |