diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 85db294..2a3345c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -83,6 +83,23 @@ cd src-tauri && cargo test bindings The database is `library.sqlite`. Schema changes are new migration steps in `src-tauri/src/cache/db.rs`. +## Flatpak + +`packaging/flatpak/` holds a manifest for local test builds. It unpacks an AppImage built from your checkout onto the GNOME runtime, which has WebKitGTK. You need `flatpak` and `flatpak-builder`, and the runtime from Flathub: + +```bash +flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo +flatpak install --user flathub org.gnome.Platform//51 org.gnome.Sdk//51 org.freedesktop.Platform.Compat.i386//26.08 org.flatpak.Builder +npm run tauri build -- --bundles appimage --config '{"bundle":{"createUpdaterArtifacts":false}}' +cp src-tauri/target/release/bundle/appimage/Guild_*_amd64.AppImage packaging/flatpak/Guild.AppImage +cd packaging/flatpak +flatpak-builder --user --install --force-clean --repo=repo build-dir cloud.biem.guild.yml +flatpak build-bundle --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakrepo repo guild.flatpak cloud.biem.guild +flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest cloud.biem.guild.yml +``` + +Install the bundle on another PC with `flatpak install --user guild.flatpak` (it fetches the runtime from Flathub) and start it with `flatpak run cloud.biem.guild`. A bundle has no remote, so Flatpak doesn't fetch the 32-bit extensions Windows games need; install them once with `flatpak install --user flathub org.freedesktop.Platform.Compat.i386//26.08 org.freedesktop.Platform.GL32.default//26.08` (on NVIDIA, the `GL32.nvidia-*` that matches the driver instead of `GL32.default`). In a Flatpak, Guild doesn't check for updates and hides the autostart switch, and it trusts Steam's `RunningAppID` without checking for the Steam process, which the sandbox can't see. It reads Steam folders and installs to `~/Games`, `/mnt`, `/media` and `/run/media`; give it other folders with `flatpak override --user --filesystem= cloud.biem.guild`. + ## Releasing Pushing a `v*` tag runs `.github/workflows/release.yml`: it runs the checks, builds the Windows NSIS installer and the Linux AppImage and `.deb` (on Ubuntu 22.04, so the AppImage runs on older glibc), signs the installer and the AppImage for the updater, and publishes a GitHub release with `latest.json`. A last job writes `latest.json` with both the `windows-x86_64` and `linux-x86_64-appimage` entries. The `.deb` doesn't auto-update: its update check finds no entry for it. The installed app checks `releases/latest/download/latest.json` for updates. Running the workflow by hand only builds and signs, and keeps the files as workflow artifacts. diff --git a/packaging/flatpak/.gitignore b/packaging/flatpak/.gitignore new file mode 100644 index 0000000..f512f27 --- /dev/null +++ b/packaging/flatpak/.gitignore @@ -0,0 +1,5 @@ +Guild.AppImage +.flatpak-builder/ +build-dir/ +repo/ +*.flatpak diff --git a/packaging/flatpak/cloud.biem.guild.desktop b/packaging/flatpak/cloud.biem.guild.desktop new file mode 100644 index 0000000..d08a500 --- /dev/null +++ b/packaging/flatpak/cloud.biem.guild.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Name=Guild +Comment=Your Steam, Epic, GOG and Amazon games in one library +Exec=guild +Icon=cloud.biem.guild +Terminal=false +Categories=Game; +Keywords=Steam;Epic;GOG;Amazon;Proton;launcher;library; +StartupWMClass=Guild diff --git a/packaging/flatpak/cloud.biem.guild.metainfo.xml b/packaging/flatpak/cloud.biem.guild.metainfo.xml new file mode 100644 index 0000000..584f4a9 --- /dev/null +++ b/packaging/flatpak/cloud.biem.guild.metainfo.xml @@ -0,0 +1,41 @@ + + + cloud.biem.guild + CC0-1.0 + GPL-3.0-or-later + Guild + Your Steam, Epic, GOG and Amazon games in one library + + TheBiemGamer + + +

Guild puts your Steam, Epic, GOG and Amazon games in one grid, next to any game you add yourself. A game you own in two stores shows up once, and you pick which store starts it.

+

Epic, GOG and Amazon games install, update, verify and uninstall from Guild itself, through one download queue you can pause and reorder. Epic and GOG cloud saves sync before and after you play. Windows games run through umu-launcher and Proton, each in its own Wine prefix.

+

Each game has a page with its description, screenshots, your playtime and how long it takes to beat. You can sort and filter the library, mark favorites, hide games and make your own collections.

+

Steam games install and start through the Steam client, which stays installed.

+
+ cloud.biem.guild.desktop + https://github.com/TheBiemGamer/guild + https://github.com/TheBiemGamer/guild/issues + + + https://raw.githubusercontent.com/TheBiemGamer/guild/main/docs/screenshot.png + The library grid + + + + + pointing + keyboard + + + 720 + + + + +

Guild runs on Linux. Epic, GOG, Amazon and added Windows games run through umu-launcher and Proton, each game in its own Wine prefix.

+
+
+
+
diff --git a/packaging/flatpak/cloud.biem.guild.png b/packaging/flatpak/cloud.biem.guild.png new file mode 100644 index 0000000..a661b6d Binary files /dev/null and b/packaging/flatpak/cloud.biem.guild.png differ diff --git a/packaging/flatpak/cloud.biem.guild.yml b/packaging/flatpak/cloud.biem.guild.yml new file mode 100644 index 0000000..4eb1844 --- /dev/null +++ b/packaging/flatpak/cloud.biem.guild.yml @@ -0,0 +1,85 @@ +id: cloud.biem.guild +runtime: org.gnome.Platform +runtime-version: '51' +sdk: org.gnome.Sdk +command: guild + +finish-args: + - --share=ipc + - --share=network + - --socket=x11 + - --socket=wayland + - --socket=pulseaudio + # GPU, and controllers for games + - --device=all + # 32-bit Wine and Proton parts + - --allow=multiarch + # Wine and pressure-vessel use syscalls the default seccomp filter blocks + - --allow=devel + # pressure-vessel shares /dev/shm with the container it starts games in + - --allow=per-app-dev-shm + # The Steam refresh token, the IGDB secret and the SteamGridDB key, in the keyring + - --talk-name=org.freedesktop.secrets + # Tray icon + - --talk-name=org.kde.StatusNotifierWatcher + # Download-finished notifications + - --talk-name=org.freedesktop.Notifications + # Steam: its library, pid, registry.vdf and art (regular and Flatpak Steam); Guild never writes there + - --filesystem=~/.steam:ro + - --filesystem=xdg-data/Steam:ro + - --filesystem=~/.var/app/com.valvesoftware.Steam:ro + # umu keeps the Steam Linux Runtime in the host's ~/.local/share/umu when in a Flatpak; pressure-vessel can only + # hand a folder on the real disk to the Flatpak portal's sub-sandbox it runs games in + - --filesystem=xdg-data/umu:create + # The default install folder for Epic, GOG and Amazon games + - --filesystem=~/Games:create + # Install folders and Steam libraries on other drives + - --filesystem=/mnt + - --filesystem=/media + - --filesystem=/run/media + +add-extensions: + org.freedesktop.Platform.Compat.i386: + directory: lib/i386-linux-gnu + version: '26.08' + + org.freedesktop.Platform.GL32: + directory: lib/i386-linux-gnu/GL + version: '1.4' + versions: 26.08;1.4 + subdirectories: true + no-autodownload: true + autodelete: false + add-ld-path: lib + merge-dirs: vulkan/icd.d;glvnd/egl_vendor.d;OpenCL/vendors;lib/dri;lib/d3d;vulkan/explicit_layer.d;vulkan/implicit_layer.d + download-if: active-gl-driver + enable-if: active-gl-driver + autoprune-unless: active-gl-driver + +modules: + - name: guild + buildsystem: simple + build-commands: + - chmod +x Guild.AppImage + - ./Guild.AppImage --appimage-extract >/dev/null + - install -Dm755 squashfs-root/usr/bin/Guild /app/bin/guild + - mkdir -p /app/lib/i386-linux-gnu/GL + # The tray library; the GNOME runtime has WebKitGTK but not this + - cp -a squashfs-root/usr/lib/libayatana-*.so* squashfs-root/usr/lib/libdbusmenu-*.so* /app/lib/ + - install -Dm644 ld.so.conf -t /app/etc + - install -Dm644 cloud.biem.guild.desktop -t /app/share/applications + - install -Dm644 cloud.biem.guild.metainfo.xml -t /app/share/metainfo + - install -Dm644 cloud.biem.guild.png /app/share/icons/hicolor/256x256/apps/cloud.biem.guild.png + sources: + # Built from this checkout, see DEVELOPMENT.md. A Flathub manifest would point at the release's AppImage. + - type: file + path: Guild.AppImage + - type: inline + dest-filename: ld.so.conf + contents: /app/lib/i386-linux-gnu + - type: file + path: cloud.biem.guild.desktop + - type: file + path: cloud.biem.guild.metainfo.xml + - type: file + path: cloud.biem.guild.png diff --git a/src-tauri/src/commands/settings.rs b/src-tauri/src/commands/settings.rs index 4310bcc..3513247 100644 --- a/src-tauri/src/commands/settings.rs +++ b/src-tauri/src/commands/settings.rs @@ -336,6 +336,8 @@ pub struct SettingsView { start_with_windows: bool, /// Picks the Linux wording where the Windows one names Windows. linux: bool, + /// A Flatpak hides the autostart switch (the sandbox can't reach the host's autostart folder) and update checks. + flatpak: bool, close_to_tray: bool, notify_downloads: bool, app_version: String, @@ -408,6 +410,7 @@ pub async fn settings_view(app: AppHandle) -> Res { gog_cloud_saves: saved.gog_cloud_saves, start_with_windows: app.autolaunch().is_enabled().unwrap_or(false), linux: cfg!(target_os = "linux"), + flatpak: crate::platform::flatpak(), close_to_tray: saved.close_to_tray, notify_downloads: saved.notify_downloads, app_version: app.package_info().version.to_string(), @@ -1070,6 +1073,7 @@ mod tests { gog_cloud_saves: false, start_with_windows: false, linux: false, + flatpak: false, close_to_tray: true, notify_downloads: true, app_version: env!("CARGO_PKG_VERSION").into(), diff --git a/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap b/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap index 93bb727..383c625 100644 --- a/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap +++ b/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap @@ -29,6 +29,7 @@ expression: view "gogCloudSaves": false, "startWithWindows": false, "linux": false, + "flatpak": false, "closeToTray": true, "notifyDownloads": true, "appVersion": "[version]", diff --git a/src-tauri/src/commands/update.rs b/src-tauri/src/commands/update.rs index ae71980..b5021e1 100644 --- a/src-tauri/src/commands/update.rs +++ b/src-tauri/src/commands/update.rs @@ -21,6 +21,10 @@ pub struct UpdateInfo { #[tauri::command] #[specta::specta] pub async fn check_update(app: AppHandle, state: State<'_, AppState>) -> Res> { + // Flathub updates a Flatpak, which must not update itself. + if crate::platform::flatpak() { + return Ok(None); + } let mut pending = state.update.lock().await; let checked = async { app.updater_builder() diff --git a/src-tauri/src/library/steam.rs b/src-tauri/src/library/steam.rs index 686a669..725f5d0 100644 --- a/src-tauri/src/library/steam.rs +++ b/src-tauri/src/library/steam.rs @@ -68,7 +68,9 @@ pub fn running_game() -> Option { let id = running_id(crate::platform::steam_running_app())?; // After a Steam crash RunningAppID keeps its last value (seen on this PC), so only // trust it while the Steam process it was written by is still alive. - steam_alive(steam_pid()?).then_some(id) + // shortcut: a Flatpak can't see host processes, so there a crash's stale id counts as running until Steam starts + // again; find another liveness signal if that shows up. + (crate::platform::flatpak() || steam_alive(steam_pid()?)).then_some(id) } pub fn download_progress(game: &Game) -> Option { diff --git a/src-tauri/src/platform.rs b/src-tauri/src/platform.rs index e57cef0..d01c304 100644 --- a/src-tauri/src/platform.rs +++ b/src-tauri/src/platform.rs @@ -69,6 +69,41 @@ pub fn open_url(url: &str) -> Result<(), crate::library::Error> { shell_open(url) } +/// Windows has no Flatpak. +#[cfg(windows)] +pub fn flatpak() -> bool { + false +} + +/// Whether Guild runs as a Flatpak: the store updates it, and the sandbox hides host processes and the host's +/// autostart folder. +#[cfg(target_os = "linux")] +pub fn flatpak() -> bool { + static FLATPAK: std::sync::LazyLock = + std::sync::LazyLock::new(|| std::path::Path::new("/.flatpak-info").exists()); + *FLATPAK +} + +/// Windows draws the tray icon itself. +#[cfg(windows)] +pub fn tray_icon_dir() -> Option { + None +} + +/// Where the tray writes its icon for the desktop's tray to read: a Flatpak's own `$XDG_RUNTIME_DIR` is private to +/// the sandbox, but `$XDG_RUNTIME_DIR/app/` is the same folder on the host. `None` keeps tray-icon's default. +#[cfg(target_os = "linux")] +pub fn tray_icon_dir() -> Option { + let runtime = std::env::var_os("XDG_RUNTIME_DIR")?; + let id = std::env::var_os("FLATPAK_ID").filter(|_| flatpak())?; + Some( + std::path::Path::new(&runtime) + .join("app") + .join(id) + .join("tray-icon"), + ) +} + /// Whether process `pid` runs and is named `image` (the name guards against a reused pid). #[cfg(windows)] pub fn pid_is(pid: u32, image: &str) -> bool { @@ -788,7 +823,13 @@ pub fn os_version() -> String { /// sets them, like "CachyOS Linux, KDE, wayland": WebKitGTK and tray bugs often depend on those two. #[cfg(target_os = "linux")] pub fn os_version() -> String { - let distro = std::fs::read_to_string("/etc/os-release") + // A Flatpak's /etc/os-release names its runtime; the host's is under /run/host. + let release = if flatpak() { + "/run/host/os-release" + } else { + "/etc/os-release" + }; + let distro = std::fs::read_to_string(release) .ok() .and_then(|text| pretty_name(&text)) .unwrap_or_else(|| "Linux".into()); diff --git a/src-tauri/src/tray.rs b/src-tauri/src/tray.rs index 2f5eea7..fc7f29d 100644 --- a/src-tauri/src/tray.rs +++ b/src-tauri/src/tray.rs @@ -90,6 +90,9 @@ pub fn build(app: &AppHandle) -> tauri::Result<()> { if let Some(icon) = app.default_window_icon() { tray = tray.icon(icon.clone()); } + if let Some(dir) = crate::platform::tray_icon_dir() { + tray = tray.temp_dir_path(dir); + } tray.build(app)?; Ok(()) } diff --git a/src-tauri/src/wine.rs b/src-tauri/src/wine.rs index ea97169..ad6bfc4 100644 --- a/src-tauri/src/wine.rs +++ b/src-tauri/src/wine.rs @@ -314,11 +314,18 @@ pub fn setting_up(key: &str) -> bool { true } -/// umu's own folder, where it keeps the Steam Linux Runtime. +/// umu's own folder, where it keeps the Steam Linux Runtime. In a Flatpak umu skips the sandbox's data folder for the +/// host's (`umu_consts.py`). fn umu_data() -> PathBuf { - directories::BaseDirs::new() - .map(|b| b.data_dir().join("umu")) - .unwrap_or_default() + let host = std::env::var_os("HOST_XDG_DATA_HOME") + .map(PathBuf::from) + .or_else(|| directories::BaseDirs::new().map(|b| b.home_dir().join(".local/share"))); + let data = if crate::platform::flatpak() { + host + } else { + directories::BaseDirs::new().map(|b| b.data_dir().to_path_buf()) + }; + data.map(|d| d.join("umu")).unwrap_or_default() } /// Whether a launch must wait: the prefix hasn't been set up (Proton writes `version` once it has), or umu still has to diff --git a/src/lib/Settings.svelte b/src/lib/Settings.svelte index c228fad..9ea5223 100644 --- a/src/lib/Settings.svelte +++ b/src/lib/Settings.svelte @@ -1153,12 +1153,14 @@

{t('settings.section.general')}

{t('settings.group.startup')}

- {@render switchRow( - 'power', - 'start_with_windows', - 'startWithWindows', - view.linux ? t('settings.startupLinux') : t('settings.startup'), - )} + {#if !view.flatpak} + {@render switchRow( + 'power', + 'start_with_windows', + 'startWithWindows', + view.linux ? t('settings.startupLinux') : t('settings.startup'), + )} + {/if} {@render switchRow('tray', 'close_to_tray', 'closeToTray', t('settings.tray'), t('settings.trayHint'))} {@render switchRow('bell', 'notify_downloads', 'notifyDownloads', t('settings.notify'))}
@@ -1389,7 +1391,7 @@ {@render tile('about')}
- {versionNote ?? t('settings.version', { version: view.appVersion })} + {(view.flatpak ? null : versionNote) ?? t('settings.version', { version: view.appVersion })}
{#if notes} - {:else} + {:else if !view.flatpak} {/if} diff --git a/src/lib/bindings.ts b/src/lib/bindings.ts index 7384a0f..08a896a 100644 --- a/src/lib/bindings.ts +++ b/src/lib/bindings.ts @@ -688,6 +688,8 @@ export type SettingsView = { startWithWindows: boolean, /** Picks the Linux wording where the Windows one names Windows. */ linux: boolean, + /** A Flatpak hides the autostart switch (the sandbox can't reach the host's autostart folder) and update checks. */ + flatpak: boolean, closeToTray: boolean, notifyDownloads: boolean, appVersion: string,