From bf4f44e8fb5d323b125f53ffe2daff225b3c3ed6 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 7 May 2025 16:54:11 -0400 Subject: [PATCH] Add instructions to allow the Steam Flatpak to launch Astra Currently Flatpak doesn't have a good way for apps to launch other apps (even legitimately) so we have to tell the user to punch a hole in the Steam Flatpak's sandbox. Oh well, at least now we guide them on how to do it. --- launcher/include/compatibilitytoolinstaller.h | 2 +- launcher/src/compatibilitytoolinstaller.cpp | 19 ++++++++++++++----- .../ui/Settings/CompatibilityToolSetup.qml | 19 +++++++++++++++++-- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/launcher/include/compatibilitytoolinstaller.h b/launcher/include/compatibilitytoolinstaller.h index fa7554d..3eb8f74 100644 --- a/launcher/include/compatibilitytoolinstaller.h +++ b/launcher/include/compatibilitytoolinstaller.h @@ -26,7 +26,7 @@ public: bool hasSteam() const; Q_SIGNALS: - void installFinished(); + void installFinished(bool flatpak); void error(QString message); void removalFinished(); void isInstalledChanged(); diff --git a/launcher/src/compatibilitytoolinstaller.cpp b/launcher/src/compatibilitytoolinstaller.cpp index d1ea2d1..1ee1379 100644 --- a/launcher/src/compatibilitytoolinstaller.cpp +++ b/launcher/src/compatibilitytoolinstaller.cpp @@ -41,10 +41,19 @@ void CompatibilityToolInstaller::installCompatibilityTool() QProcess::execute(QStringLiteral("chmod"), {QStringLiteral("+x"), astraToolDir.absoluteFilePath(QStringLiteral("wrapper.sh"))}); - // we need a run script to escape the compatibility tool quirk where it runs everything in the current directory - const auto runScriptContents = QStringLiteral( - "$STEAM_COMPAT_CLIENT_INSTALL_PATH/compatibilitytools.d/astra/steamwrap & p1=$!\nflatpak run zone.xiv.astra --steam \"$@\" & p2=$!\nwait -n\n[ \"$?\" " - "-gt 1 ] || kill \"$p1\" \"$p2\"\nwait"); + QString runScriptContents; + if (steamType == SteamType::Flatpak) { + runScriptContents = QStringLiteral( + "$STEAM_COMPAT_CLIENT_INSTALL_PATH/compatibilitytools.d/astra/steamwrap & p1=$!\nflatpak-spawn --host -- flatpak run zone.xiv.astra --steam \"$@\" " + "& p2=$!\nwait -n\n[ \"$?\" " + "-gt 1 ] || kill \"$p1\" \"$p2\"\nwait"); + + } else { + runScriptContents = QStringLiteral( + "$STEAM_COMPAT_CLIENT_INSTALL_PATH/compatibilitytools.d/astra/steamwrap & p1=$!\nflatpak run zone.xiv.astra --steam \"$@\" & p2=$!\nwait -n\n[ " + "\"$?\" " + "-gt 1 ] || kill \"$p1\" \"$p2\"\nwait"); + } QFile runScriptFile(astraToolDir.absoluteFilePath(QStringLiteral("run.sh"))); runScriptFile.open(QIODevice::WriteOnly | QIODevice::Text); @@ -91,7 +100,7 @@ void CompatibilityToolInstaller::installCompatibilityTool() compatibilityToolFile.write(compatibilityToolContents.toUtf8()); compatibilityToolFile.close(); - Q_EMIT installFinished(); + Q_EMIT installFinished(steamType == SteamType::Flatpak); Q_EMIT isInstalledChanged(); } diff --git a/launcher/ui/Settings/CompatibilityToolSetup.qml b/launcher/ui/Settings/CompatibilityToolSetup.qml index c90acf8..8d4f2ad 100644 --- a/launcher/ui/Settings/CompatibilityToolSetup.qml +++ b/launcher/ui/Settings/CompatibilityToolSetup.qml @@ -7,6 +7,7 @@ import QtQuick.Controls as QQC2 import org.kde.kirigami as Kirigami import org.kde.kirigamiaddons.formcard as FormCard +import org.kde.kquickcontrolsaddons as KQuickControlsAddons import zone.xiv.astra @@ -61,12 +62,26 @@ FormCard.FormCardPage { parent: page.QQC2.Overlay.overlay } + readonly property Kirigami.Action copyCommandAction: Kirigami.Action { + icon.name: "edit-copy-symbolic" + text: i18n("Copy Command") + onTriggered: clipboard.content = "flatpak override com.valvesoftware.Steam --talk-name=org.freedesktop.Flatpak" + } + + readonly property KQuickControlsAddons.Clipboard clipboard: KQuickControlsAddons.Clipboard {} + data: Connections { target: page.installer - function onInstallFinished(): void { + function onInstallFinished(flatpak: bool): void { page.errorDialog.title = i18n("Successful Installation"); - page.errorDialog.subtitle = i18n("You need to relaunch Steam for Astra to show up as a Compatibility Tool."); + if (flatpak) { + page.errorDialog.subtitle = i18n("You need to relaunch Steam for Astra to show up as a Compatibility Tool.\n\nSince you are using the Steam Flatpak, you must give it permissions to allow it to launch Astra:\nflatpak override com.valvesoftware.Steam --talk-name=org.freedesktop.Flatpak"); + page.errorDialog.customFooterActions = [copyCommandAction]; + } else { + page.errorDialog.subtitle = i18n("You need to relaunch Steam for Astra to show up as a Compatibility Tool."); + page.errorDialog.customFooterActions = []; + } page.errorDialog.open(); }