Commit 9a36c4da authored by Ivan Čukić's avatar Ivan Čukić 👁

Support execution of shell scripts on activity events

In addition to opening a file and starting an application specified
by a .desktop file, allow execution of shell scripts when activity
is started/stopped/switched to/switched from.

Reviewers: davidedmundson, mart

Reviewed By: davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D28069
parent 93d81bd0
......@@ -117,10 +117,14 @@ void RunApplicationPlugin::executeIn(const QString &path) const
QDir directory(path);
for (const auto& item: directory.entryList(QDir::Files)) {
QString filePath = directory.filePath(item);
KService service(filePath);
if (service.isValid() && service.isApplication()) {
qCDebug(KAMD_LOG_APPLICATION) << "Starting: " << service.exec();
if (QFileInfo fileInfo(filePath); fileInfo.suffix() == "sh" && fileInfo.isExecutable()) {
qCDebug(KAMD_LOG_APPLICATION) << "Starting a shell script: " << filePath;
QProcess::startDetached(filePath, QStringList());
} else if (KService service(filePath); service.isValid() && service.isApplication()) {
qCDebug(KAMD_LOG_APPLICATION) << "Starting application: " << service.exec();
QProcess::startDetached(service.exec(), QStringList());
} else {
qCDebug(KAMD_LOG_APPLICATION) << "Openning file: " << QUrl::fromLocalFile(filePath);
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
......
Markdown is supported
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