kinit: use the home path as default working directory

because klauncher is D-Bus service

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-12 09:30:09 +03:00
parent feb9e9405c
commit 8da3ce890f
2 changed files with 6 additions and 9 deletions

View file

@ -301,15 +301,14 @@ void KLauncherAdaptor::cleanup()
bool KLauncherAdaptor::start_program(const QString &app, const QStringList &args, bool KLauncherAdaptor::start_program(const QString &app, const QStringList &args,
const QStringList &envs, quint64 window, bool temp) const QStringList &envs, quint64 window, bool temp)
{ {
return start_program_with_workdir(app, args, envs, window, temp, QDir::currentPath()); return start_program_with_workdir(app, args, envs, window, temp, QDir::homePath());
} }
bool KLauncherAdaptor::start_program_with_workdir(const QString &app, const QStringList &args, bool KLauncherAdaptor::start_program_with_workdir(const QString &app, const QStringList &args,
const QStringList &envs, quint64 window, const QStringList &envs, quint64 window,
bool temp, const QString &workdir) bool temp, const QString &workdir)
{ {
qint64 pid = 0; return startProgram(app, args, envs, window, temp, workdir, m_startuptimeout);
return startProgram(app, args, envs, window, temp, workdir, pid, m_startuptimeout);
} }
void KLauncherAdaptor::setLaunchEnv(const QString &name, const QString &value) void KLauncherAdaptor::setLaunchEnv(const QString &name, const QString &value)
@ -355,12 +354,11 @@ bool KLauncherAdaptor::start_service_by_storage_id(const QString &serviceName,
} }
QString programworkdir = kservice->path(); QString programworkdir = kservice->path();
if (programworkdir.isEmpty()) { if (programworkdir.isEmpty()) {
programworkdir = QDir::currentPath(); programworkdir = QDir::homePath();
} }
kDebug() << "starting" << kservice->entryPath() << urls; kDebug() << "starting" << kservice->entryPath() << urls;
const QString program = programandargs.takeFirst(); const QString program = programandargs.takeFirst();
qint64 pid = 0; return startProgram(program, programandargs, envs, window, temp, programworkdir, m_startuptimeout, kservice);
return startProgram(program, programandargs, envs, window, temp, programworkdir, pid, m_startuptimeout, kservice);
} }
bool KLauncherAdaptor::start_service_by_url(const QString &url, const QStringList &envs, bool KLauncherAdaptor::start_service_by_url(const QString &url, const QStringList &envs,
@ -447,7 +445,7 @@ QString KLauncherAdaptor::findExe(const QString &app) const
bool KLauncherAdaptor::startProgram(const QString &app, const QStringList &args, const QStringList &envs, bool KLauncherAdaptor::startProgram(const QString &app, const QStringList &args, const QStringList &envs,
const quint64 window, const bool temp, const QString &workdir, const quint64 window, const bool temp, const QString &workdir,
qint64 &pid, const qint64 timeout, const KService::Ptr kservice) const qint64 timeout, const KService::Ptr kservice)
{ {
const QString appexe = findExe(app); const QString appexe = findExe(app);
if (appexe.isEmpty()) { if (appexe.isEmpty()) {
@ -486,7 +484,6 @@ bool KLauncherAdaptor::startProgram(const QString &app, const QStringList &args,
return false; return false;
} }
pid = process->pid();
return true; return true;
} }

View file

@ -104,7 +104,7 @@ private Q_SLOTS:
private: private:
QString findExe(const QString &app) const; QString findExe(const QString &app) const;
bool startProgram(const QString &app, const QStringList &args, const QStringList &envs, bool startProgram(const QString &app, const QStringList &args, const QStringList &envs,
const quint64 window, const bool temp, const QString &workdir, qint64 &pid, const quint64 window, const bool temp, const QString &workdir,
const qint64 timeout, const KService::Ptr kservice = KService::Ptr(nullptr)); const qint64 timeout, const KService::Ptr kservice = KService::Ptr(nullptr));
QProcessEnvironment m_environment; QProcessEnvironment m_environment;