From 6bde01321f61a5140f08eeddffe8d396f860b0d3 Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 4 May 2022 08:55:42 +0200 Subject: [PATCH] try to blind fix autostarting for linux, now should also take all CLI args into account when generating desktop file --- .../com.github.rssguard.desktop.autostart | 2 +- .../miscellaneous/systemfactory.cpp | 26 +++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/resources/desktop/com.github.rssguard.desktop.autostart b/resources/desktop/com.github.rssguard.desktop.autostart index 3979067ae..2e0e89e97 100644 --- a/resources/desktop/com.github.rssguard.desktop.autostart +++ b/resources/desktop/com.github.rssguard.desktop.autostart @@ -4,7 +4,7 @@ Type=Application Terminal=false Name=RSS Guard TryExec=%1 -Exec=%1 +Exec=%2 Hidden=false X-GNOME-Autostart-Delay=15 X-LXQt-Need-Tray=true \ No newline at end of file diff --git a/src/librssguard/miscellaneous/systemfactory.cpp b/src/librssguard/miscellaneous/systemfactory.cpp index 0019db216..2493d9b2b 100644 --- a/src/librssguard/miscellaneous/systemfactory.cpp +++ b/src/librssguard/miscellaneous/systemfactory.cpp @@ -175,11 +175,27 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) { try { QString desktop_file_contents = QString::fromUtf8(IOFactory::readFile(source_autostart_desktop_file)); -#if defined(IS_FLATPAK_BUILD) - desktop_file_contents = desktop_file_contents.arg(QSL("flatpak run %1").arg(QSL(APP_REVERSE_NAME))); -#else - desktop_file_contents = desktop_file_contents.arg(QSL(APP_LOW_NAME)); -#endif + QStringList args = qApp->rawCliArgs(); + auto std_args = boolinq::from(args) + .select([](const QString& arg) { + if (arg.contains(QL1S(" ")) && !arg.startsWith(QL1S("\""))) { + return QSL("\"%1\"").arg(arg); + } + else { + return arg; + } + }) + .toStdList(); + args = FROM_STD_LIST(QStringList, std_args); + + QString app_run_line = args.join(QL1C(' ')); + desktop_file_contents = desktop_file_contents.arg(args.at(0), app_run_line); + + // #if defined(IS_FLATPAK_BUILD) + // desktop_file_contents = desktop_file_contents.arg(QSL("flatpak run %1").arg(QSL(APP_REVERSE_NAME))); + // #else + // desktop_file_contents = desktop_file_contents.arg(QSL(APP_LOW_NAME)); + // #endif IOFactory::writeFile(destination_file, desktop_file_contents.toUtf8()); }