Commit e275ca73 authored by David Edmundson's avatar David Edmundson
Browse files

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
parent 4a541edf
......@@ -24,6 +24,8 @@
#include <QSessionManager>
#include <QDebug>
#include <QMessageBox>
#include <QDBusConnection>
#include <QDBusMessage>
#include <KAboutData>
#include <KQuickAddons/QtQuickSettings>
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment