From e00eae6a87543982d7b59a6a1fdeec341c0ed46e Mon Sep 17 00:00:00 2001 From: Skythrew Date: Wed, 3 Jan 2024 15:05:45 +0100 Subject: [PATCH] fix: start discord rpc before game --- src/games/genshin/game.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/games/genshin/game.rs b/src/games/genshin/game.rs index 771d097..ce6b5ca 100644 --- a/src/games/genshin/game.rs +++ b/src/games/genshin/game.rs @@ -277,6 +277,19 @@ pub fn run() -> anyhow::Result<()> { 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 let variables = command @@ -290,19 +303,7 @@ pub fn run() -> anyhow::Result<()> { // obviously doesn't exist command.current_dir(config.game.path.for_edition(config.launcher.edition)) .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 { std::thread::sleep(std::time::Duration::from_secs(3));