Skip to content

Commit 12f366e

Browse files
Fabian Müllerfmoc
authored andcommitted
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.
1 parent 610b293 commit 12f366e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/common/utility_unix.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <QCoreApplication>
2323
#include <QDir>
2424
#include <QFile>
25+
#include <QSettings>
2526
#include <QStandardPaths>
2627
#include <QString>
2728
#include <QTextStream>
@@ -79,7 +80,7 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName,
7980
return;
8081
}
8182

82-
auto autostartApplicationPath = []() {
83+
auto autostartApplicationPath = []() -> QString {
8384
// $APPIMAGE will be set to the AppImage's path by the AppImage runtime
8485
// if it is set, we can assume to be run from within an AppImage
8586
// 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,
8889
return Utility::appImageLocation();
8990
}
9091

92+
// 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
93+
// if installed as a native package generated by linuxdeploy-plugin-native_packages, a linuxdeploy.conf file will be available that points to the
94+
// location of the installed AppDir
95+
QString linuxdeployConfPath = qApp->applicationDirPath() + QStringLiteral("/linuxdeploy.conf");
96+
97+
if (QFile(linuxdeployConfPath).exists()) {
98+
QSettings linuxdeployConf(linuxdeployConfPath, QSettings::IniFormat);
99+
100+
const auto appdirInstallatedPath = linuxdeployConf.value(QStringLiteral("native_packages/appdir_installed_path"));
101+
if (!appdirInstallatedPath.isNull()) {
102+
return appdirInstallatedPath.toString() + QStringLiteral("/AppRun");
103+
}
104+
}
105+
106+
// otherwise, we just use the application binary's own path, which should work for distribution-packaged installations and also for development
91107
return QCoreApplication::applicationFilePath();
92108
}();
93109

0 commit comments

Comments
 (0)