From 12f366ec3383cd09eb4d7dff5598e45dc5dd16dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20M=C3=BCller?= Date: Tue, 31 Oct 2023 11:46:32 +0100 Subject: [PATCH] Ensure correct look of auto-started ownCloud client When installed as a native package (built by our new packaging system), we must make sure to run the client with the environment variables it is supposed to run with. Otherwise, its look and feel fall back to some unintended defaults. --- src/common/utility_unix.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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(); }();