feat: added launcher.auto_close config

This commit is contained in:
Observer KRypt0n_ 2023-07-29 18:22:29 +02:00
parent 372fbac7a4
commit 3e8946c2e2
No known key found for this signature in database
GPG key ID: 844DA47BA25FE1E2
9 changed files with 62 additions and 9 deletions

View file

@ -93,6 +93,7 @@ impl From<&JsonValue> for Gamescope {
} }
impl Gamescope { impl Gamescope {
// TODO: temporary workaround for transition period, will be removed in future
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
Command::new("gamescope").arg("--help").output() Command::new("gamescope").arg("--help").output()
@ -148,7 +149,7 @@ impl Gamescope {
gamescope += if Gamescope::is_legacy_version() { gamescope += if Gamescope::is_legacy_version() {
" -n" " -n"
} else { } else {
" -F integer" " -S integer"
} }
} }

View file

@ -53,7 +53,9 @@ pub struct Launcher {
pub discord_rpc: DiscordRpc, pub discord_rpc: DiscordRpc,
#[cfg(feature = "environment-emulation")] #[cfg(feature = "environment-emulation")]
pub environment: Environment pub environment: Environment,
pub auto_close: bool
} }
impl Default for Launcher { impl Default for Launcher {
@ -70,7 +72,9 @@ impl Default for Launcher {
discord_rpc: DiscordRpc::default(), discord_rpc: DiscordRpc::default(),
#[cfg(feature = "environment-emulation")] #[cfg(feature = "environment-emulation")]
environment: Environment::default() environment: Environment::default(),
auto_close: false
} }
} }
} }
@ -124,6 +128,11 @@ impl From<&JsonValue> for Launcher {
environment: match value.get("environment") { environment: match value.get("environment") {
Some(value) => serde_json::from_value(value.clone()).unwrap_or(default.environment), Some(value) => serde_json::from_value(value.clone()).unwrap_or(default.environment),
None => default.environment None => default.environment
},
auto_close: match value.get("auto_close") {
Some(value) => value.as_bool().unwrap_or(default.auto_close),
None => default.auto_close
} }
} }
} }

View file

@ -324,5 +324,9 @@ pub fn run() -> anyhow::Result<()> {
Sessions::update(current, config.get_wine_prefix_path())?; Sessions::update(current, config.get_wine_prefix_path())?;
} }
if config.launcher.auto_close {
std::process::exit(0);
}
Ok(()) Ok(())
} }

View file

@ -41,7 +41,9 @@ pub struct Launcher {
pub repairer: Repairer, pub repairer: Repairer,
#[cfg(feature = "discord-rpc")] #[cfg(feature = "discord-rpc")]
pub discord_rpc: DiscordRpc pub discord_rpc: DiscordRpc,
pub auto_close: bool
} }
impl Default for Launcher { impl Default for Launcher {
@ -54,7 +56,9 @@ impl Default for Launcher {
repairer: Repairer::default(), repairer: Repairer::default(),
#[cfg(feature = "discord-rpc")] #[cfg(feature = "discord-rpc")]
discord_rpc: DiscordRpc::default() discord_rpc: DiscordRpc::default(),
auto_close: false
} }
} }
} }
@ -98,6 +102,11 @@ impl From<&JsonValue> for Launcher {
Some(value) => DiscordRpc::from(value), Some(value) => DiscordRpc::from(value),
None => default.discord_rpc None => default.discord_rpc
}, },
auto_close: match value.get("auto_close") {
Some(value) => value.as_bool().unwrap_or(default.auto_close),
None => default.auto_close
}
} }
} }
} }

View file

@ -257,5 +257,9 @@ pub fn run() -> anyhow::Result<()> {
Sessions::update(current, config.get_wine_prefix_path())?; Sessions::update(current, config.get_wine_prefix_path())?;
} }
if config.launcher.auto_close {
std::process::exit(0);
}
Ok(()) Ok(())
} }

View file

@ -41,7 +41,9 @@ pub struct Launcher {
pub repairer: Repairer, pub repairer: Repairer,
#[cfg(feature = "discord-rpc")] #[cfg(feature = "discord-rpc")]
pub discord_rpc: DiscordRpc pub discord_rpc: DiscordRpc,
pub auto_close: bool
} }
impl Default for Launcher { impl Default for Launcher {
@ -54,7 +56,9 @@ impl Default for Launcher {
repairer: Repairer::default(), repairer: Repairer::default(),
#[cfg(feature = "discord-rpc")] #[cfg(feature = "discord-rpc")]
discord_rpc: DiscordRpc::default() discord_rpc: DiscordRpc::default(),
auto_close: false
} }
} }
} }
@ -98,6 +102,11 @@ impl From<&JsonValue> for Launcher {
Some(value) => DiscordRpc::from(value), Some(value) => DiscordRpc::from(value),
None => default.discord_rpc None => default.discord_rpc
}, },
auto_close: match value.get("auto_close") {
Some(value) => value.as_bool().unwrap_or(default.auto_close),
None => default.auto_close
}
} }
} }
} }

View file

@ -243,5 +243,9 @@ pub fn run() -> anyhow::Result<()> {
Sessions::update(current, config.get_wine_prefix_path())?; Sessions::update(current, config.get_wine_prefix_path())?;
} }
if config.launcher.auto_close {
std::process::exit(0);
}
Ok(()) Ok(())
} }

View file

@ -44,7 +44,9 @@ pub struct Launcher {
pub repairer: Repairer, pub repairer: Repairer,
#[cfg(feature = "discord-rpc")] #[cfg(feature = "discord-rpc")]
pub discord_rpc: DiscordRpc pub discord_rpc: DiscordRpc,
pub auto_close: bool
} }
impl Default for Launcher { impl Default for Launcher {
@ -58,7 +60,9 @@ impl Default for Launcher {
repairer: Repairer::default(), repairer: Repairer::default(),
#[cfg(feature = "discord-rpc")] #[cfg(feature = "discord-rpc")]
discord_rpc: DiscordRpc::default() discord_rpc: DiscordRpc::default(),
auto_close: false
} }
} }
} }
@ -106,6 +110,11 @@ impl From<&JsonValue> for Launcher {
discord_rpc: match value.get("discord_rpc") { discord_rpc: match value.get("discord_rpc") {
Some(value) => DiscordRpc::from(value), Some(value) => DiscordRpc::from(value),
None => default.discord_rpc None => default.discord_rpc
},
auto_close: match value.get("auto_close") {
Some(value) => value.as_bool().unwrap_or(default.auto_close),
None => default.auto_close
} }
} }
} }

View file

@ -258,5 +258,9 @@ pub fn run() -> anyhow::Result<()> {
Sessions::update(current, config.get_wine_prefix_path())?; Sessions::update(current, config.get_wine_prefix_path())?;
} }
if config.launcher.auto_close {
std::process::exit(0);
}
Ok(()) Ok(())
} }