feat: implemented #5

Hope I didn't break code logic
This commit is contained in:
Observer KRypt0n_ 2023-07-29 13:02:22 +02:00
parent a73ec58594
commit 8fbc568f14
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2

View file

@ -1,19 +1,16 @@
use std::process::Command;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue; use serde_json::Value as JsonValue;
use std::process::Command;
pub mod size; pub mod size;
pub mod framerate; pub mod framerate;
pub mod window_type; pub mod window_type;
pub mod prelude { pub mod prelude {
pub use super::Gamescope; pub use super::Gamescope;
pub use super::size::Size; pub use super::size::Size;
pub use super::framerate::Framerate; pub use super::framerate::Framerate;
pub use super::window_type::WindowType; pub use super::window_type::WindowType;
} }
@ -98,18 +95,15 @@ impl From<&JsonValue> for Gamescope {
impl Gamescope { impl Gamescope {
fn is_legacy_version() -> bool { fn is_legacy_version() -> bool {
// gamescope doesn't have --version, so parsing --help instead // gamescope doesn't have --version, so parsing --help instead
match Command::new("/usr/bin/gamescope").arg("--help").output() { Command::new("gamescope").arg("--help").output()
Err(_) => true, // if no --filter, then it's legacy version
Ok(output) => String::from_utf8(output.stderr) .map(|help| !String::from_utf8_lossy(&help.stderr).contains("-F, --filter"))
.unwrap_or_default() .unwrap_or(true)
.lines()
.find(|s| s.contains("-F, --filter"))
.is_none() // if no --filter, then it's legacy version
}
} }
pub fn get_command(&self) -> Option<String> { pub fn get_command(&self) -> Option<String> {
// https://github.com/bottlesdevs/Bottles/blob/b908311348ed1184ead23dd76f9d8af41ff24082/src/backend/wine/winecommand.py#L478 // https://github.com/bottlesdevs/Bottles/blob/b908311348ed1184ead23dd76f9d8af41ff24082/src/backend/wine/winecommand.py#L478
// https://github.com/ValveSoftware/gamescope#options
if self.enabled { if self.enabled {
let mut gamescope = String::from("gamescope"); let mut gamescope = String::from("gamescope");