Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.1] Fixed the autostart for AppImages. See #2504. #2753

Merged
merged 1 commit into from
Dec 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/common/utility_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

#include <QStandardPaths>
#include <QtGlobal>

namespace OCC {

Expand Down Expand Up @@ -71,12 +72,18 @@ void setLaunchOnStartup_private(const QString &appName, const QString &guiName,
qCWarning(lcUtility) << "Could not write auto start entry" << desktopFileLocation;
return;
}
// When running inside an AppImage, we need to set the path to the
// AppImage instead of the path to the executable
const QString appImagePath = qEnvironmentVariable("APPIMAGE");
const bool runningInsideAppImage = !appImagePath.isNull() && QFile::exists(appImagePath);
const QString executablePath = runningInsideAppImage ? appImagePath : QCoreApplication::applicationFilePath();

QTextStream ts(&iniFile);
ts.setCodec("UTF-8");
ts << QLatin1String("[Desktop Entry]") << endl
<< QLatin1String("Name=") << guiName << endl
<< QLatin1String("GenericName=") << QLatin1String("File Synchronizer") << endl
<< QLatin1String("Exec=") << QCoreApplication::applicationFilePath() << " --background" << endl
<< QLatin1String("Exec=\"") << executablePath << "\" --background" << endl
<< QLatin1String("Terminal=") << "false" << endl
<< QLatin1String("Icon=") << APPLICATION_ICON_NAME << endl
<< QLatin1String("Categories=") << QLatin1String("Network") << endl
Expand Down