From: Hannah Rittich Date: Fri, 18 Dec 2020 12:13:55 +0000 (+0100) Subject: Fixed the autostart for AppImages. See #2504. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~458^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5fc778bfaa33b65f352e7df229bc5b69d18eb1bc;p=nextcloud-desktop.git Fixed the autostart for AppImages. See #2504. Signed-off-by: Hannah Rittich --- diff --git a/src/common/utility_unix.cpp b/src/common/utility_unix.cpp index a5f257d07..010408395 100644 --- a/src/common/utility_unix.cpp +++ b/src/common/utility_unix.cpp @@ -18,6 +18,7 @@ */ #include +#include namespace OCC { @@ -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