diff --git a/src/common/utility_unix.cpp b/src/common/utility_unix.cpp index 76c3be5d21b..f9eddf08776 100644 --- a/src/common/utility_unix.cpp +++ b/src/common/utility_unix.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -79,7 +80,7 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName, return; } - auto autostartApplicationPath = []() { + auto autostartApplicationPath = []() -> QString { // $APPIMAGE will be set to the AppImage's path by the AppImage runtime // if it is set, we can assume to be run from within an AppImage // in that case, the desktop file should point to the AppImage rather than the @@ -88,6 +89,21 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName, return Utility::appImageLocation(); } + // we need to launch the client via its provided AppRun script (or at least source the AppRun hooks) to make sure it is displayed correctly + // if installed as a native package generated by linuxdeploy-plugin-native_packages, a linuxdeploy.conf file will be available that points to the + // location of the installed AppDir + QString linuxdeployConfPath = qApp->applicationDirPath() + QStringLiteral("/linuxdeploy.conf"); + + if (QFile(linuxdeployConfPath).exists()) { + QSettings linuxdeployConf(linuxdeployConfPath, QSettings::IniFormat); + + const auto appdirInstallatedPath = linuxdeployConf.value(QStringLiteral("native_packages/appdir_installed_path")); + if (!appdirInstallatedPath.isNull()) { + return appdirInstallatedPath.toString() + QStringLiteral("/AppRun"); + } + } + + // otherwise, we just use the application binary's own path, which should work for distribution-packaged installations and also for development return QCoreApplication::applicationFilePath(); }();