1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-05-13 21:07:46 +00:00

Support installing the compatibility tool for Flatpak Steam

See #35
This commit is contained in:
Joshua Goins 2025-05-07 16:36:25 -04:00
parent ff1d6e172d
commit 3e064e91ce
3 changed files with 38 additions and 14 deletions

View file

@ -32,7 +32,12 @@ Q_SIGNALS:
void isInstalledChanged();
private:
QDir steamDir() const;
enum class SteamType {
NotFound,
Native,
Flatpak,
};
std::pair<SteamType, QDir> findSteamType() const;
LauncherCore &m_launcher;
};
};

View file

@ -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::SteamType, QDir> 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"

View file

@ -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