2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 07:35:12 +00:00

Add a method to get flatpak ID

This commit is contained in:
Ilya Fedin
2020-07-13 02:54:06 +04:00
committed by John Preston
parent 256e976167
commit a6fe5c08ad

View File

@@ -132,6 +132,18 @@ uint FileChooserPortalVersion() {
} }
#endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION #endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION
QString FlatpakID() {
static const auto Result = [] {
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
return QString::fromLatin1(qgetenv("FLATPAK_ID"));
} else {
return GetLauncherBasename();
}
}();
return Result;
}
QString ProcessNameByPID(const QString &pid) { QString ProcessNameByPID(const QString &pid) {
constexpr auto kMaxPath = 1024; constexpr auto kMaxPath = 1024;
char result[kMaxPath] = { 0 }; char result[kMaxPath] = { 0 };
@@ -694,16 +706,7 @@ QString AppRuntimeDirectory() {
QStandardPaths::RuntimeLocation); QStandardPaths::RuntimeLocation);
if (InFlatpak()) { if (InFlatpak()) {
const auto flatpakId = [&] { runtimeDir += qsl("/app/") + FlatpakID();
if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) {
return QString::fromLatin1(qgetenv("FLATPAK_ID"));
} else {
return GetLauncherBasename();
}
}();
runtimeDir += qsl("/app/")
+ flatpakId;
} }
if (!QFileInfo::exists(runtimeDir)) { // non-systemd distros if (!QFileInfo::exists(runtimeDir)) { // non-systemd distros
@@ -786,7 +789,7 @@ QString GetLauncherFilename() {
QString GetIconName() { QString GetIconName() {
static const auto Result = InFlatpak() static const auto Result = InFlatpak()
? GetLauncherBasename() ? FlatpakID()
: kIconName.utf16(); : kIconName.utf16();
return Result; return Result;
} }