From 598c64351401e4eb41cd003a10d01aa3a243daa5 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 1 Sep 2021 01:53:24 +0200 Subject: [PATCH] Refresh plasmashell when the ShellPackage changes from the LnF At the moment issues a --replace that will restart the package, will need to look into why it crashes when tearing up the former shell package. --- kcms/lookandfeel/kcm.cpp | 7 +++++++ kcms/lookandfeel/kcm.h | 2 ++ shell/dbus/org.kde.PlasmaShell.xml | 1 + shell/main.cpp | 6 +----- shell/shellcorona.cpp | 14 ++++++++++++++ shell/shellcorona.h | 4 ++++ 6 files changed, 29 insertions(+), 5 deletions(-) diff --git a/kcms/lookandfeel/kcm.cpp b/kcms/lookandfeel/kcm.cpp index 3c29c28fb..60335605a 100644 --- a/kcms/lookandfeel/kcm.cpp +++ b/kcms/lookandfeel/kcm.cpp @@ -410,6 +410,12 @@ void KCMLookandFeel::save() QDBusConnection::sessionBus().send(message); } + if (m_plasmashellChanged) { + QDBusMessage message = + QDBusMessage::createSignal(QStringLiteral("/PlasmaShell"), QStringLiteral("org.kde.PlasmaShell"), QStringLiteral("refreshCurrentShell")); + QDBusConnection::sessionBus().send(message); + } + // autostart if (m_resetDefaultLayout) { // remove all the old package to autostart @@ -759,6 +765,7 @@ void KCMLookandFeel::setWindowPlacement(const QString &value) void KCMLookandFeel::setShellPackage(const QString &value) { writeNewDefaults(QStringLiteral("plasmashellrc"), QStringLiteral("Shell"), QStringLiteral("ShellPackage"), value); + m_plasmashellChanged = true; } void KCMLookandFeel::setWindowDecoration(const QString &library, const QString &theme) diff --git a/kcms/lookandfeel/kcm.h b/kcms/lookandfeel/kcm.h index 8ab2c3224..f0b7f2d8c 100644 --- a/kcms/lookandfeel/kcm.h +++ b/kcms/lookandfeel/kcm.h @@ -138,4 +138,6 @@ private: bool m_applyShellPackage : 1 = true; bool m_resetDefaultLayout : 1; bool m_applyWindowDecoration : 1; + + bool m_plasmashellChanged = false; }; diff --git a/shell/dbus/org.kde.PlasmaShell.xml b/shell/dbus/org.kde.PlasmaShell.xml index 8583e0732..dd47aca35 100644 --- a/shell/dbus/org.kde.PlasmaShell.xml +++ b/shell/dbus/org.kde.PlasmaShell.xml @@ -23,5 +23,6 @@ + diff --git a/shell/main.cpp b/shell/main.cpp index 489f78193..c8141c19f 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -98,10 +98,6 @@ int main(int argc, char *argv[]) app.setQuitOnLastWindowClosed(false); - KSharedConfig::Ptr startupConf = KSharedConfig::openConfig(QStringLiteral("plasmashellrc")); - KConfigGroup startupConfGroup(startupConf, "Shell"); - const QString defaultShell = startupConfGroup.readEntry("ShellPackage", qEnvironmentVariable("PLASMA_DEFAULT_SHELL", "org.kde.plasma.desktop")); - bool replace = false; ShellCorona *corona; @@ -116,7 +112,7 @@ int main(int argc, char *argv[]) QCommandLineOption shellPluginOption(QStringList() << QStringLiteral("p") << QStringLiteral("shell-plugin"), i18n("Force loading the given shell plugin"), QStringLiteral("plugin"), - defaultShell); + ShellCorona::defaultShell()); QCommandLineOption standaloneOption(QStringList() << QStringLiteral("a") << QStringLiteral("standalone"), i18n("Load plasmashell as a standalone application, needs the shell-plugin option to be specified")); diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index d453b51d2..95c73505a 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -2127,6 +2127,20 @@ void ShellCorona::activateTaskManagerEntry(int index) } } +QString ShellCorona::defaultShell() +{ + KSharedConfig::Ptr startupConf = KSharedConfig::openConfig(QStringLiteral("plasmashellrc")); + KConfigGroup startupConfGroup(startupConf, "Shell"); + return startupConfGroup.readEntry("ShellPackage", qEnvironmentVariable("PLASMA_DEFAULT_SHELL", "org.kde.plasma.desktop")); +} + +void ShellCorona::refreshCurrentShell() +{ + KSharedConfig::openConfig(QStringLiteral("plasmashellrc"))->reparseConfiguration(); + // FIXME: setShell(defaultShell()); + QProcess::startDetached("plasmashell", {"--replace"}); +} + // Desktop corona handler #include "moc_shellcorona.cpp" diff --git a/shell/shellcorona.h b/shell/shellcorona.h index 8d5008768..18c0b5b3e 100644 --- a/shell/shellcorona.h +++ b/shell/shellcorona.h @@ -106,6 +106,8 @@ public: QString defaultContainmentPlugin() const; + static QString defaultShell(); + Q_SIGNALS: void glInitializationFailed(); @@ -158,6 +160,8 @@ public Q_SLOTS: return m_panelViews.count(); } + void refreshCurrentShell(); + protected Q_SLOTS: /** * Loads the layout and performs the needed checks