Skip to content
Closed
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
6 changes: 4 additions & 2 deletions src/common/utility_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,16 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName,
// 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 QString flatpakId = qEnvironmentVariable("FLATPAK_ID");
const bool runningInsideAppImage = !appImagePath.isNull() && QFile::exists(appImagePath);
const QString executablePath = runningInsideAppImage ? appImagePath : QCoreApplication::applicationFilePath();
const bool runningInsideFlatpak = !flatpakId.isNull();
const QString executablePath = runningInsideAppImage ? QLatin1String("\"%1\"").arg(appImagePath) : runningInsideFlatpak ? QLatin1String("flatpak run %1").arg(flatpakId) : QLatin1String("\"%1\"").arg(QCoreApplication::applicationFilePath());

QTextStream ts(&iniFile);
ts << QLatin1String("[Desktop Entry]\n")
<< QLatin1String("Name=") << guiName << QLatin1Char('\n')
<< QLatin1String("GenericName=") << QLatin1String("File Synchronizer\n")
<< QLatin1String("Exec=\"") << executablePath << "\" --background\n"
<< QLatin1String("Exec=") << executablePath << " --background\n"
<< QLatin1String("Terminal=") << "false\n"
<< QLatin1String("Icon=") << APPLICATION_ICON_NAME << QLatin1Char('\n')
<< QLatin1String("Categories=") << QLatin1String("Network\n")
Expand Down
Loading