diff --git a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp index b2fe79b6b3..1c721e4c2e 100644 --- a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/linux/launcher_linux.h" -#include "platform/linux/specific_linux.h" #include "core/crash_reports.h" #include "core/update_checker.h" @@ -50,7 +49,26 @@ Launcher::Launcher(int argc, char *argv[]) void Launcher::initHook() { QApplication::setAttribute(Qt::AA_DisableSessionManager, true); - QApplication::setDesktopFileName(GetLauncherFilename()); + QApplication::setDesktopFileName([] { + if (!Core::UpdaterDisabled() && !cExeName().isEmpty()) { + const auto appimagePath = qsl("file://%1%2") + .arg(cExeDir()) + .arg(cExeName()) + .toUtf8(); + + char md5Hash[33] = { 0 }; + hashMd5Hex( + appimagePath.constData(), + appimagePath.size(), + md5Hash); + + return qsl("appimagekit_%1-%2.desktop") + .arg(md5Hash) + .arg(AppName.utf16().replace(' ', '_')); + } + + return qsl(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME) ".desktop"); + }()); } bool Launcher::launchUpdater(UpdaterLaunch action) { diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 605412c3d5..139667ea6f 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -873,7 +873,8 @@ void MainWindow::updateIconCounters() { #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION if (UseUnityCounter()) { const auto launcherUrl = Glib::ustring( - "application://" + GetLauncherFilename().toStdString()); + "application://" + + QGuiApplication::desktopFileName().toStdString()); const auto counterSlice = std::min(counter, 9999); std::map dbusUnityProperties; diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 10ec299035..9ec221bcc2 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include +#include #include #include @@ -463,7 +464,7 @@ NotificationData::NotificationData( _hints["category"] = Glib::Variant::create("im.received"); _hints["desktop-entry"] = Glib::Variant::create( - GetLauncherBasename().toStdString()); + QGuiApplication::desktopFileName().chopped(8).toStdString()); _notificationClosedSignalId = _dbusConnection->signal_subscribe( sigc::mem_fun(this, &NotificationData::signalEmitted), diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 370d76b3b7..ad7935575c 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -256,7 +256,7 @@ QString FlatpakID() { if (!qEnvironmentVariableIsEmpty("FLATPAK_ID")) { return qEnvironmentVariable("FLATPAK_ID"); } else { - return GetLauncherBasename(); + return cExeName(); } }(); @@ -275,7 +275,7 @@ bool GenerateDesktopFile( if (!QDir(targetPath).exists()) QDir().mkpath(targetPath); const auto sourceFile = kDesktopFile.utf16(); - const auto targetFile = targetPath + GetLauncherFilename(); + const auto targetFile = targetPath + QGuiApplication::desktopFileName(); QString fileText; @@ -407,37 +407,6 @@ QString SingleInstanceLocalServerName(const QString &hash) { } } -QString GetLauncherBasename() { - static const auto Result = [&] { - if (!Core::UpdaterDisabled() && !cExeName().isEmpty()) { - const auto appimagePath = qsl("file://%1%2") - .arg(cExeDir()) - .arg(cExeName()) - .toUtf8(); - - char md5Hash[33] = { 0 }; - hashMd5Hex( - appimagePath.constData(), - appimagePath.size(), - md5Hash); - - return qsl("appimagekit_%1-%2") - .arg(md5Hash) - .arg(AppName.utf16().replace(' ', '_')); - } - - return qsl(MACRO_TO_STRING(TDESKTOP_LAUNCHER_BASENAME)); - }(); - - return Result; -} - -QString GetLauncherFilename() { - static const auto Result = GetLauncherBasename() - + qsl(".desktop"); - return Result; -} - QString GetIconName() { static const auto Result = InFlatpak() ? FlatpakID() @@ -616,7 +585,7 @@ int psFixPrevious() { namespace Platform { void start() { - LOG(("Launcher filename: %1").arg(GetLauncherFilename())); + LOG(("Launcher filename: %1").arg(QGuiApplication::desktopFileName())); qputenv("PULSE_PROP_application.name", AppName.utf8()); qputenv("PULSE_PROP_application.icon_name", GetIconName().toLatin1()); @@ -873,7 +842,7 @@ void psAutoStart(bool start, bool silent) { if (start) { GenerateDesktopFile(autostart, qsl("-autostart"), silent); } else { - QFile::remove(autostart + GetLauncherFilename()); + QFile::remove(autostart + QGuiApplication::desktopFileName()); } } } diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.h b/Telegram/SourceFiles/platform/linux/specific_linux.h index 21cc925379..c1ce882bab 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.h +++ b/Telegram/SourceFiles/platform/linux/specific_linux.h @@ -19,8 +19,6 @@ bool InFlatpak(); bool InSnap(); QString AppRuntimeDirectory(); -QString GetLauncherBasename(); -QString GetLauncherFilename(); QString GetIconName(); void InstallLauncher(bool force = false);