Try to restore updater-dependent binary path logic

Now that the file generating logic is simplier, it may be not that hard to maintain
This commit is contained in:
Ilya Fedin 2023-04-01 22:56:09 +04:00 committed by John Preston
parent 40e65eb1e6
commit 3064a41014
4 changed files with 18 additions and 9 deletions

View File

@ -1724,7 +1724,6 @@ endif()
if (LINUX AND DESKTOP_APP_USE_PACKAGED)
include(GNUInstallDirs)
configure_file("../lib/xdg/org.telegram.desktop.desktop" "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.desktop" @ONLY)
configure_file("../lib/xdg/org.telegram.desktop.metainfo.xml" "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.metainfo.xml" @ONLY)
generate_appdata_changelog(Telegram "${CMAKE_SOURCE_DIR}/changelog.txt" "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.metainfo.xml")
install(TARGETS Telegram RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}")
@ -1735,6 +1734,6 @@ if (LINUX AND DESKTOP_APP_USE_PACKAGED)
install(FILES "Resources/art/icon128.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps" RENAME "telegram.png")
install(FILES "Resources/art/icon256.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps" RENAME "telegram.png")
install(FILES "Resources/art/icon512.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/512x512/apps" RENAME "telegram.png")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install(FILES "../lib/xdg/org.telegram.desktop.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.telegram.desktop.metainfo.xml" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo")
endif()

View File

@ -1730,7 +1730,9 @@ void Application::startShortcuts() {
void Application::RegisterUrlScheme() {
base::Platform::RegisterUrlScheme(base::Platform::UrlSchemeDescriptor{
.executable = cExeDir() + cExeName(),
.executable = (!Platform::IsLinux() || !Core::UpdaterDisabled())
? (cExeDir() + cExeName())
: cExeName(),
.arguments = Sandbox::Instance().customWorkingDir()
? u"-workdir \"%1\""_q.arg(cWorkingDir())
: QString(),

View File

@ -422,7 +422,11 @@ bool GenerateDesktopFile(
target->set_string(
group,
"TryExec",
KShell::joinArgs({ cExeDir() + cExeName() }).replace(
KShell::joinArgs({
!Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName()
}).replace(
'\\',
qstr("\\\\")).toStdString());
}
@ -430,7 +434,9 @@ bool GenerateDesktopFile(
if (target->has_key(group, "Exec")) {
if (group == "Desktop Entry" && !args.isEmpty()) {
QStringList exec;
exec.append(cExeDir() + cExeName());
exec.append(!Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName());
if (Core::Sandbox::Instance().customWorkingDir()) {
exec.append(u"-workdir"_q);
exec.append(cWorkingDir());
@ -451,7 +457,9 @@ bool GenerateDesktopFile(
qstr("\\")));
if (!exec.isEmpty()) {
exec[0] = cExeDir() + cExeName();
exec[0] = !Core::UpdaterDisabled()
? (cExeDir() + cExeName())
: cExeName();
if (Core::Sandbox::Instance().customWorkingDir()) {
exec.insert(1, u"-workdir"_q);
exec.insert(2, cWorkingDir());

View File

@ -1,8 +1,8 @@
[Desktop Entry]
Name=Telegram Desktop
Comment=Official desktop version of Telegram messaging app
TryExec=@CMAKE_INSTALL_FULL_BINDIR@/telegram-desktop
Exec=@CMAKE_INSTALL_FULL_BINDIR@/telegram-desktop -- %u
TryExec=telegram-desktop
Exec=telegram-desktop -- %u
Icon=telegram
Terminal=false
StartupWMClass=TelegramDesktop
@ -16,6 +16,6 @@ X-GNOME-UsesNotifications=true
X-GNOME-SingleWindow=true
[Desktop Action quit]
Exec=@CMAKE_INSTALL_FULL_BINDIR@/telegram-desktop -quit
Exec=telegram-desktop -quit
Name=Quit Telegram
Icon=application-exit