From 3064a41014907187239afba84bb5e999009b8105 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 1 Apr 2023 22:56:09 +0400 Subject: [PATCH] Try to restore updater-dependent binary path logic Now that the file generating logic is simplier, it may be not that hard to maintain --- Telegram/CMakeLists.txt | 3 +-- Telegram/SourceFiles/core/application.cpp | 4 +++- .../SourceFiles/platform/linux/specific_linux.cpp | 14 +++++++++++--- lib/xdg/org.telegram.desktop.desktop | 6 +++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 8165566f1..2419fa804 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -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() diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index e251ca7de..4c1bc7233 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -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(), diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index b0a54d483..ab1a50e2e 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -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()); diff --git a/lib/xdg/org.telegram.desktop.desktop b/lib/xdg/org.telegram.desktop.desktop index 4d6dbeb48..38fbe2c63 100644 --- a/lib/xdg/org.telegram.desktop.desktop +++ b/lib/xdg/org.telegram.desktop.desktop @@ -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