diff --git a/Modules/about-distro/src/Module.cpp b/Modules/about-distro/src/Module.cpp --- a/Modules/about-distro/src/Module.cpp +++ b/Modules/about-distro/src/Module.cpp @@ -21,7 +21,9 @@ #include "Module.h" #include "ui_Module.h" +#include #include +#include #include #include @@ -107,7 +109,7 @@ // https://bugs.kde.org/show_bug.cgi?id=366158 // When a KCM loads fast enough do a blocking load via the constructor. - // Otherwise there is a notciable rendering gap where dummy/no data is + // Otherwise there is a noticeable rendering gap where dummy/no data is // shown. Makes it look bad. load(); } @@ -171,7 +173,7 @@ } // Since Plasma version detection isn't based on a library query it can fail - // in weird cases; instead of admiting defeat we simply hide everything :P + // in weird cases; instead of admitting defeat we simply hide everything :P QString plasma = plasmaVersion(); if (plasma.isEmpty()) { ui->plasma->hide(); @@ -243,6 +245,35 @@ QString Module::plasmaVersion() const { + // Try to get the version from `plasmashell --version` first, just in case the + // distro-provided .desktop file is wrong + // See https://bugs.kde.org/show_bug.cgi?id=377994 + QString plasmashellPath = "/usr/bin/plasmashell"; + QFileInfo checkFile(plasmashellPath); + if (checkFile.exists() && checkFile.isFile()) { + QProcess *process = new QProcess; + process->setProcessChannelMode(QProcess::MergedChannels); + QString command = plasmashellPath.append (QString(" --version")); + process->start(command); + if (process->waitForStarted()) { + process->waitForFinished(); + if (process->exitCode() == 0) { + QByteArray data = process->readAll(); + QString plasmaVersion = QString(data); + process->close(); + if (! plasmaVersion.isEmpty()) { + // Process the returned string to only be a numerical version + if (plasmaVersion.startsWith("plasmashell ")) { + plasmaVersion.remove(QString("plasmashell ")); + return plasmaVersion.simplified(); + } + } + } + } + } + + // The /usr/bin/plasmashell process didn't exist, exited nonzero, + // or produced odd output; fall back to the distro-provided .desktop file const QStringList &filePaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("xsessions/plasma.desktop"));