From 3e064e91ce12a939eba2182facbf494d39e32242 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 7 May 2025 16:36:25 -0400 Subject: [PATCH] Support installing the compatibility tool for Flatpak Steam See #35 --- launcher/include/compatibilitytoolinstaller.h | 9 +++- launcher/src/compatibilitytoolinstaller.cpp | 41 +++++++++++++------ zone.xiv.astra.yml | 2 + 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/launcher/include/compatibilitytoolinstaller.h b/launcher/include/compatibilitytoolinstaller.h index aa3576b..fa7554d 100644 --- a/launcher/include/compatibilitytoolinstaller.h +++ b/launcher/include/compatibilitytoolinstaller.h @@ -32,7 +32,12 @@ Q_SIGNALS: void isInstalledChanged(); private: - QDir steamDir() const; + enum class SteamType { + NotFound, + Native, + Flatpak, + }; + std::pair findSteamType() const; LauncherCore &m_launcher; -}; \ No newline at end of file +}; diff --git a/launcher/src/compatibilitytoolinstaller.cpp b/launcher/src/compatibilitytoolinstaller.cpp index 9209fca..5808060 100644 --- a/launcher/src/compatibilitytoolinstaller.cpp +++ b/launcher/src/compatibilitytoolinstaller.cpp @@ -16,13 +16,13 @@ CompatibilityToolInstaller::CompatibilityToolInstaller(LauncherCore &launcher, Q void CompatibilityToolInstaller::installCompatibilityTool() { - const QDir steamSteamDir = steamDir(); - if (!steamSteamDir.exists()) { + const auto [steamType, steamDir] = findSteamType(); + if (steamType == SteamType::NotFound) { Q_EMIT error(i18n("Could not find a Steam installation.")); return; } - const QDir compatToolDir = steamSteamDir.absoluteFilePath(QStringLiteral("compatibilitytools.d")); + const QDir compatToolDir = steamDir.absoluteFilePath(QStringLiteral("compatibilitytools.d")); const QDir astraToolDir = compatToolDir.absoluteFilePath(QStringLiteral("astra")); if (astraToolDir.exists()) { Q_EMIT error(i18n("Astra's Compatibility Tool is already installed.")); @@ -97,13 +97,13 @@ void CompatibilityToolInstaller::installCompatibilityTool() void CompatibilityToolInstaller::removeCompatibilityTool() { - const QDir steamSteamDir = steamDir(); - if (!steamSteamDir.exists()) { + const auto [steamType, steamDir] = findSteamType(); + if (steamType == SteamType::NotFound) { Q_EMIT error(i18n("Could not find a Steam installation.")); return; } - const QDir compatToolDir = steamSteamDir.absoluteFilePath(QStringLiteral("compatibilitytools.d")); + const QDir compatToolDir = steamDir.absoluteFilePath(QStringLiteral("compatibilitytools.d")); QDir astraToolDir = compatToolDir.absoluteFilePath(QStringLiteral("astra")); if (!astraToolDir.exists()) { Q_EMIT error(i18n("Astra's Compatibility Tool is not installed.")); @@ -118,21 +118,38 @@ void CompatibilityToolInstaller::removeCompatibilityTool() bool CompatibilityToolInstaller::isInstalled() const { - const QDir compatToolDir = steamDir().absoluteFilePath(QStringLiteral("compatibilitytools.d")); + const QDir compatToolDir = findSteamType().second.absoluteFilePath(QStringLiteral("compatibilitytools.d")); const QDir astraToolDir = compatToolDir.absoluteFilePath(QStringLiteral("astra")); return astraToolDir.exists(); } bool CompatibilityToolInstaller::hasSteam() const { - return steamDir().exists(); + return findSteamType().first != SteamType::NotFound; } -QDir CompatibilityToolInstaller::steamDir() const +std::pair CompatibilityToolInstaller::findSteamType() const { - const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::HomeLocation)[0]; - const QDir steamDir = appDataDir.absoluteFilePath(QStringLiteral(".steam")); - return steamDir.absoluteFilePath(QStringLiteral("steam")); + // prefer flatpak + { + const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::HomeLocation)[0]; + const QDir flatpakDataDir = appDataDir.absoluteFilePath(QStringLiteral(".var/app/com.valvesoftware.Steam/data/Steam/")); + if (flatpakDataDir.exists()) { + return {SteamType::Flatpak, flatpakDataDir}; + } + } + + // fallback to native + { + const QDir appDataDir = QStandardPaths::standardLocations(QStandardPaths::StandardLocation::HomeLocation)[0]; + const QDir steamDir = appDataDir.absoluteFilePath(QStringLiteral(".steam")); + const QDir steamDataDir = steamDir.absoluteFilePath(QStringLiteral("steam")); + if (steamDataDir.exists()) { + return {SteamType::Native, steamDataDir}; + } + } + + return {SteamType::NotFound, QDir()}; } #include "moc_compatibilitytoolinstaller.cpp" diff --git a/zone.xiv.astra.yml b/zone.xiv.astra.yml index 17ab67a..96a61b2 100644 --- a/zone.xiv.astra.yml +++ b/zone.xiv.astra.yml @@ -14,6 +14,8 @@ finish-args: - --socket=fallback-x11 - --share=network - --filesystem=home + # We need to install compatibility tools for Flatpak Steam + - --filesystem=~/.var/app/com.valvesoftware.Steam/data/Steam/compatibilitytools.d/:rw - --socket=pulseaudio # Allow access to the GNOME secret service API and to talk to the GNOME keyring daemon - --talk-name=org.freedesktop.secrets