refactor: optimized a bit legacy gamescope support
This commit is contained in:
parent
244720cc4b
commit
8de2dff6c9
1 changed files with 19 additions and 10 deletions
|
@ -92,14 +92,23 @@ impl From<&JsonValue> for Gamescope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: temporary workaround for transition period, will be removed in future
|
||||||
|
#[cached::proc_macro::cached]
|
||||||
|
fn is_legacy_version() -> bool {
|
||||||
|
// gamescope doesn't have --version, so parsing --help instead
|
||||||
|
Command::new("gamescope").arg("--help").output()
|
||||||
|
|
||||||
|
// if no --filter, then it's legacy version
|
||||||
|
.map(|help| !String::from_utf8_lossy(&help.stderr).contains("-F, --filter"))
|
||||||
|
|
||||||
|
// If failed to launch gamescope, then yes, it's legacy (it's not but meh)
|
||||||
|
.unwrap_or(true)
|
||||||
|
}
|
||||||
|
|
||||||
impl Gamescope {
|
impl Gamescope {
|
||||||
// TODO: temporary workaround for transition period, will be removed in future
|
/// Check if available gamescope version is legacy (<3.12.0)
|
||||||
fn is_legacy_version() -> bool {
|
pub fn is_legacy_version() -> bool {
|
||||||
// gamescope doesn't have --version, so parsing --help instead
|
is_legacy_version()
|
||||||
Command::new("gamescope").arg("--help").output()
|
|
||||||
// if no --filter, then it's legacy version
|
|
||||||
.map(|help| !String::from_utf8_lossy(&help.stderr).contains("-F, --filter"))
|
|
||||||
.unwrap_or(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_command(&self) -> Option<String> {
|
pub fn get_command(&self) -> Option<String> {
|
||||||
|
@ -146,7 +155,7 @@ impl Gamescope {
|
||||||
|
|
||||||
// Set integer scaling
|
// Set integer scaling
|
||||||
if self.integer_scaling {
|
if self.integer_scaling {
|
||||||
gamescope += if Gamescope::is_legacy_version() {
|
gamescope += if Self::is_legacy_version() {
|
||||||
" -n"
|
" -n"
|
||||||
} else {
|
} else {
|
||||||
" -S integer"
|
" -S integer"
|
||||||
|
@ -155,7 +164,7 @@ impl Gamescope {
|
||||||
|
|
||||||
// Set FSR support
|
// Set FSR support
|
||||||
if self.fsr {
|
if self.fsr {
|
||||||
gamescope += if Gamescope::is_legacy_version() {
|
gamescope += if Self::is_legacy_version() {
|
||||||
" -U"
|
" -U"
|
||||||
} else {
|
} else {
|
||||||
" -F fsr"
|
" -F fsr"
|
||||||
|
@ -164,7 +173,7 @@ impl Gamescope {
|
||||||
|
|
||||||
// Set NIS (Nvidia Image Scaling) support
|
// Set NIS (Nvidia Image Scaling) support
|
||||||
if self.nis {
|
if self.nis {
|
||||||
gamescope += if Gamescope::is_legacy_version() {
|
gamescope += if Self::is_legacy_version() {
|
||||||
" -Y"
|
" -Y"
|
||||||
} else {
|
} else {
|
||||||
" -F nis"
|
" -F nis"
|
||||||
|
|
Loading…
Reference in a new issue