fix: start discord rpc before game

This commit is contained in:
Skythrew 2024-01-03 15:05:45 +01:00
parent 5f309f68df
commit e00eae6a87

View file

@ -277,6 +277,19 @@ pub fn run() -> anyhow::Result<()> {
Sessions::apply(current, config.get_wine_prefix_path())?; Sessions::apply(current, config.get_wine_prefix_path())?;
} }
// Start Discord RPC just before the game
#[cfg(feature = "discord-rpc")]
let rpc = if config.launcher.discord_rpc.enabled {
Some(DiscordRpc::new(config.launcher.discord_rpc.clone().into()))
} else {
None
};
#[cfg(feature = "discord-rpc")]
if let Some(rpc) = &rpc {
rpc.update(RpcUpdates::Connect)?;
}
// Run command // Run command
let variables = command let variables = command
@ -290,19 +303,7 @@ pub fn run() -> anyhow::Result<()> {
// obviously doesn't exist // obviously doesn't exist
command.current_dir(config.game.path.for_edition(config.launcher.edition)) command.current_dir(config.game.path.for_edition(config.launcher.edition))
.spawn()?.wait_with_output()?; .spawn()?.wait_with_output()?;
#[cfg(feature = "discord-rpc")]
let rpc = if config.launcher.discord_rpc.enabled {
Some(DiscordRpc::new(config.launcher.discord_rpc.clone().into()))
} else {
None
};
#[cfg(feature = "discord-rpc")]
if let Some(rpc) = &rpc {
rpc.update(RpcUpdates::Connect)?;
}
loop { loop {
std::thread::sleep(std::time::Duration::from_secs(3)); std::thread::sleep(std::time::Duration::from_secs(3));