mirror of https://github.com/procxx/kepka.git
Fix creating of autostart launcher in snap
This commit is contained in:
parent
a0e7ef61fc
commit
e62f727135
|
@ -43,6 +43,7 @@ using Platform::File::internal::EscapeShell;
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs;
|
constexpr auto kDesktopFile = ":/misc/telegramdesktop.desktop"_cs;
|
||||||
|
constexpr auto kSnapLauncherDir = "/var/lib/snapd/desktop/applications/"_cs;
|
||||||
|
|
||||||
bool XDGDesktopPortalPresent = false;
|
bool XDGDesktopPortalPresent = false;
|
||||||
|
|
||||||
|
@ -125,19 +126,25 @@ bool GenerateDesktopFile(const QString &targetPath, const QString &args) {
|
||||||
DEBUG_LOG(("App Info: placing .desktop file to %1").arg(targetPath));
|
DEBUG_LOG(("App Info: placing .desktop file to %1").arg(targetPath));
|
||||||
if (!QDir(targetPath).exists()) QDir().mkpath(targetPath);
|
if (!QDir(targetPath).exists()) QDir().mkpath(targetPath);
|
||||||
|
|
||||||
|
const auto sourceFile = [&] {
|
||||||
|
if (InSnap()) {
|
||||||
|
return kSnapLauncherDir.utf16() + GetLauncherFilename();
|
||||||
|
} else {
|
||||||
|
return kDesktopFile.utf16();
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
const auto targetFile = targetPath + GetLauncherFilename();
|
const auto targetFile = targetPath + GetLauncherFilename();
|
||||||
|
|
||||||
QString fileText;
|
QString fileText;
|
||||||
|
|
||||||
QFile source(kDesktopFile.utf16());
|
QFile source(sourceFile);
|
||||||
if (source.open(QIODevice::ReadOnly)) {
|
if (source.open(QIODevice::ReadOnly)) {
|
||||||
QTextStream s(&source);
|
QTextStream s(&source);
|
||||||
fileText = s.readAll();
|
fileText = s.readAll();
|
||||||
source.close();
|
source.close();
|
||||||
} else {
|
} else {
|
||||||
LOG(("App Error: Could not open '%1' for read")
|
LOG(("App Error: Could not open '%1' for read").arg(sourceFile));
|
||||||
.arg(kDesktopFile.utf16()));
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,10 +547,19 @@ void psAutoStart(bool start, bool silent) {
|
||||||
SandboxAutostart(start);
|
SandboxAutostart(start);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
const auto autostart =
|
const auto autostart = [&] {
|
||||||
QStandardPaths::writableLocation(
|
if (InSnap()) {
|
||||||
QStandardPaths::GenericConfigLocation)
|
QDir realHomeDir(home);
|
||||||
+ qsl("/autostart/");
|
realHomeDir.cd(qsl("../../.."));
|
||||||
|
|
||||||
|
return realHomeDir
|
||||||
|
.absoluteFilePath(qsl(".config/autostart/"));
|
||||||
|
} else {
|
||||||
|
return QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::GenericConfigLocation)
|
||||||
|
+ qsl("/autostart/");
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
if (start) {
|
if (start) {
|
||||||
GenerateDesktopFile(autostart, qsl("-autostart"));
|
GenerateDesktopFile(autostart, qsl("-autostart"));
|
||||||
|
|
Loading…
Reference in New Issue