diff --git a/Readme.md b/Readme.md index 7018144..bccf5e5 100644 --- a/Readme.md +++ b/Readme.md @@ -42,6 +42,8 @@ There is also an [AUR package](https://aur.archlinux.org/packages/steam-boilr-gu - [x] Show games from other platforms in your steam library - [x] Automatically download art from [SteamGridDB](https://www.steamgriddb.com/) +- [x] Customize your Steam games art +- [x] Backup your shortcuts - [x] Cross Platform (Windows, Linux, Mac, Steam Deck) - [x] Standalone / No install needed - [x] Small (~3mb on disk) @@ -60,6 +62,7 @@ There is also an [AUR package](https://aur.archlinux.org/packages/steam-boilr-gu - [x] [Rare](https://github.com/Dummerle/Rare/releases) - [x] [Heroic Launcher](https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher) (Linux Only) - [x] [Amazon Games](https://gaming.amazon.com) (Windows Only) +- [x] [Flatpak](https://flathub.org/) (Linux Only) - [ ] XBox/Microsoft Store integration diff --git a/src/defaultconfig.toml b/src/defaultconfig.toml index e49852e..c1669b7 100644 --- a/src/defaultconfig.toml +++ b/src/defaultconfig.toml @@ -43,6 +43,10 @@ default_launch_through_heroic = true [amazon] enabled = true + +[flatpak] +enabled = true + [steam] create_collections = false optimize_for_big_picture = false diff --git a/src/flatpak/mod.rs b/src/flatpak/mod.rs new file mode 100644 index 0000000..fc511aa --- /dev/null +++ b/src/flatpak/mod.rs @@ -0,0 +1,5 @@ +mod platform; +mod settings; + +pub use platform::*; +pub use settings::*; diff --git a/src/flatpak/platform.rs b/src/flatpak/platform.rs new file mode 100644 index 0000000..1b51217 --- /dev/null +++ b/src/flatpak/platform.rs @@ -0,0 +1,78 @@ +use serde::{Deserialize, Serialize}; + +use crate::platform::{Platform, SettingsValidity}; +use std::error::Error; + +use super::FlatpakSettings; +use steam_shortcuts_util::{shortcut::ShortcutOwned, Shortcut}; + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct FlatpakPlatform { + pub settings: FlatpakSettings, +} + +#[derive(Debug, Clone)] +pub struct FlatpakApp { + pub name: String, + pub id: String, +} + +impl From for ShortcutOwned { + fn from(app: FlatpakApp) -> Self { + let launch_parameter = format!("run {}", app.id); + Shortcut::new("0", &app.name, "flatpak", "", "", "", &launch_parameter).to_owned() + } +} + +impl Platform> for FlatpakPlatform { + fn enabled(&self) -> bool { + self.settings.enabled + } + + fn name(&self) -> &str { + "Flatpak" + } + + fn get_shortcuts(&self) -> Result, Box> { + use std::process::Command; + let mut command = Command::new("flatpak"); + let output = command + .arg("list") + .arg("--app") + .arg("--columns=name,application") + .output()?; + let output_string = String::from_utf8_lossy(&output.stdout).to_string(); + let mut result = vec![]; + for line in output_string.lines() { + let mut split = line.split("\t"); + if let Some(name) = split.next() { + if let Some(id) = split.next() { + result.push(FlatpakApp { + name: name.to_string(), + id: id.to_string(), + }) + } + } + } + Ok(result) + } + + fn settings_valid(&self) -> crate::platform::SettingsValidity { + let shortcuts_res = self.get_shortcuts(); + match shortcuts_res { + Ok(_) => SettingsValidity::Valid, + Err(err) => SettingsValidity::Invalid { + reason: format!("{}", err), + }, + } + } + + #[cfg(target_family = "unix")] + fn create_symlinks(&self) -> bool { + false + } + + fn needs_proton(&self, _input: &FlatpakApp) -> bool { + false + } +} diff --git a/src/flatpak/settings.rs b/src/flatpak/settings.rs new file mode 100644 index 0000000..fe1dfd5 --- /dev/null +++ b/src/flatpak/settings.rs @@ -0,0 +1,6 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct FlatpakSettings { + pub enabled: bool, +} diff --git a/src/main.rs b/src/main.rs index 17fb3a7..046a734 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ mod steamgriddb; mod sync; mod ui; mod uplay; +mod flatpak; use std::error::Error; fn main() -> Result<(), Box> { diff --git a/src/settings.rs b/src/settings.rs index b5dcc40..90df663 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,8 +1,8 @@ use crate::{ amazon::AmazonSettings, config::get_config_file, egs::EpicGamesLauncherSettings, - gog::GogSettings, heroic::HeroicSettings, itch::ItchSettings, legendary::LegendarySettings, - lutris::settings::LutrisSettings, origin::OriginSettings, steam::SteamSettings, - steamgriddb::SteamGridDbSettings, uplay::UplaySettings, + flatpak::FlatpakSettings, gog::GogSettings, heroic::HeroicSettings, itch::ItchSettings, + legendary::LegendarySettings, lutris::settings::LutrisSettings, origin::OriginSettings, + steam::SteamSettings, steamgriddb::SteamGridDbSettings, uplay::UplaySettings, }; use config::{Config, ConfigError, Environment, File}; @@ -25,6 +25,7 @@ pub struct Settings { pub lutris: LutrisSettings, pub heroic: HeroicSettings, pub amazon: AmazonSettings, + pub flatpak: FlatpakSettings, } impl Settings { diff --git a/src/sync/synchronization.rs b/src/sync/synchronization.rs index b0a7821..d9ef4d9 100644 --- a/src/sync/synchronization.rs +++ b/src/sync/synchronization.rs @@ -3,6 +3,7 @@ use tokio::sync::watch::Sender; use crate::{ egs::EpicPlatform, + flatpak::FlatpakPlatform, legendary::LegendaryPlatform, lutris::lutris_platform::LutrisPlatform, platform::Platform, @@ -217,6 +218,10 @@ pub fn get_platform_shortcuts(settings: &Settings) -> Vec<(String, Vec