kcontrol: openbox hack

if openbox still fails to launch check the system log, it has not been
maintained for years so I do not expect a crash to get fixed

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-12-11 04:37:49 +02:00
parent fe23eb4d95
commit f9c0870657

View file

@ -23,6 +23,7 @@
#include <ktimerdialog.h>
#include <kselectionowner.h>
#include <kprocess.h>
#include <kshell.h>
#include <qthread.h>
#include <qfileinfo.h>
#include <qdbusinterface.h>
@ -55,6 +56,28 @@ void killWM()
kselectionowner.release();
}
bool startWM(const QString &wmexec)
{
// HACK: openbox crashes shortly after it is started if started from this process so start it
// via klauncher
if (wmexec.contains(QLatin1String("openbox"))) {
QDBusInterface klauncher(
"org.kde.klauncher", "/KLauncher","org.kde.KLauncher",
QDBusConnection::sessionBus()
);
QStringList wmcommand = KShell::splitArgs(wmexec);
if (wmcommand.isEmpty()) {
return false;
}
const QString wmprog = wmcommand.takeFirst();
QDBusReply<void> reply = klauncher.call("exec_blind", wmprog, wmcommand);
return reply.isValid();
}
KProcess kproc;
kproc.setShellCommand(wmexec);
return (kproc.startDetached() > 0);
}
CfgWm::CfgWm(QWidget *parent)
: QWidget(parent)
, Ui::WmConfig_UI()
@ -160,9 +183,7 @@ bool CfgWm::tryWmLaunch()
bool ret = false;
setEnabled(false);
killWM();
KProcess kproc(this);
kproc.setShellCommand(currentWmData().exec);
if (kproc.startDetached()) {
if (startWM(currentWmData().exec)) {
// it's forked into background
ret = true;
@ -219,8 +240,7 @@ bool CfgWm::tryWmLaunch()
if (wmkey.toLower() == oldwm) {
WmData oldwmdata = wms.value(wmkey);
killWM();
kproc.setShellCommand(oldwmdata.exec);
kproc.startDetached();
startWM(oldwmdata.exec);
break;
}
}