1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(appimage): Use external binary path when enabling autorun from appimage

Fix #6241
This commit is contained in:
Anthony Bilinski 2021-09-22 19:33:21 -07:00
parent 5852d61914
commit da5c165f41
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -38,9 +38,21 @@ QString getAutostartFilePath(QString dir)
return dir + "/qTox - " + Settings::getInstance().getCurrentProfile() + ".desktop";
}
inline QString currentCommandLine()
QString currentBinPath()
{
return "\"" + QApplication::applicationFilePath() + "\" -p \""
const auto env = QProcessEnvironment::systemEnvironment();
const auto appImageEnvKey = QStringLiteral("APPIMAGE");
if (env.contains(appImageEnvKey)) {
return env.value(appImageEnvKey);
} else {
return QApplication::applicationFilePath();
}
}
inline QString profileRunCommand()
{
return "\"" + currentBinPath() + "\" -p \""
+ Settings::getInstance().getCurrentProfile() + "\"";
}
}
@ -56,7 +68,7 @@ bool Platform::setAutorun(bool on)
desktop.write("Type=Application\n");
desktop.write("Name=qTox\n");
desktop.write("Exec=");
desktop.write(currentCommandLine().toUtf8());
desktop.write(profileRunCommand().toUtf8());
desktop.write("\n");
desktop.close();
return true;