From e275ca733bb8fc83560a78ada8b04850561f966f Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 11 Apr 2018 11:29:06 +0100 Subject: [PATCH] Add plasmashell --replace Summary: Calls the existing quit signal on a running plasma then tries to start in the normal way. It's meant partly to make my own development workflow a bit easier, but also to make it one less line on bugzilla when I want people to give me debug output. Test Plan: Ran with existing plasma running Ran without an existing plasma running Reviewers: #plasma, apol Reviewed By: apol Subscribers: apol, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D12092 --- shell/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shell/main.cpp b/shell/main.cpp index 58f6334db..b2c8b3183 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include @@ -102,6 +104,8 @@ int main(int argc, char *argv[]) QCommandLineOption standaloneOption(QStringList() << QStringLiteral("a") << QStringLiteral("standalone"), i18n("Load plasmashell as a standalone application, needs the shell-plugin option to be specified")); + QCommandLineOption replaceOption({QStringLiteral("replace")}, + i18n("Replace an existing instance")); QCommandLineOption testOption(QStringList() << QStringLiteral("test"), i18n("Enables test mode and specifies the layout javascript file to set up the testing environment"), i18n("file"), QStringLiteral("layout.js")); @@ -111,6 +115,7 @@ int main(int argc, char *argv[]) cliOptions.addOption(shellPluginOption); cliOptions.addOption(standaloneOption); cliOptions.addOption(testOption); + cliOptions.addOption(replaceOption); aboutData.setupCommandLine(&cliOptions); cliOptions.process(app); @@ -165,6 +170,14 @@ int main(int argc, char *argv[]) cliOptions.showHelp(1); } } + + if (cliOptions.isSet(replaceOption)) { + auto message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.plasmashell"), + QStringLiteral("/MainApplication"), + QStringLiteral("org.qtproject.Qt.QCoreApplication"), + QStringLiteral("quit")); + QDBusConnection::sessionBus().call(message); //deliberately block until it's done, so we register the name after the app quits + } } KDBusService service(KDBusService::Unique);