feat: send DiscordRPC::Update messages each 3 seconds
This commit is contained in:
parent
b2aa2d1fd8
commit
0f2163d22d
5 changed files with 31 additions and 1 deletions
|
@ -50,6 +50,9 @@ pub enum RpcUpdates {
|
|||
icon: String
|
||||
},
|
||||
|
||||
/// Update RPC connection with already set activity params
|
||||
Update,
|
||||
|
||||
/// Clear RPC activity
|
||||
ClearActivity
|
||||
}
|
||||
|
@ -102,6 +105,13 @@ impl DiscordRpc {
|
|||
}
|
||||
}
|
||||
|
||||
RpcUpdates::Update => {
|
||||
if connected {
|
||||
client.set_activity(Self::get_activity(¶ms))
|
||||
.expect("Failed to update discord rpc activity");
|
||||
}
|
||||
}
|
||||
|
||||
RpcUpdates::ClearActivity => {
|
||||
if connected {
|
||||
client.clear_activity().expect("Failed to clear discord rpc activity");
|
||||
|
|
|
@ -302,6 +302,11 @@ pub fn run() -> anyhow::Result<()> {
|
|||
if !output.contains("GenshinImpact.e") && !output.contains("YuanShen.exe") && !output.contains("unlocker.exe") {
|
||||
break;
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
if let Some(rpc) = &rpc {
|
||||
rpc.update(RpcUpdates::Update)?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
|
|
|
@ -246,6 +246,11 @@ pub fn run() -> anyhow::Result<()> {
|
|||
if !output.contains("BH3.exe") {
|
||||
break;
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
if let Some(rpc) = &rpc {
|
||||
rpc.update(RpcUpdates::Update)?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
|
|
|
@ -228,9 +228,14 @@ pub fn run() -> anyhow::Result<()> {
|
|||
let output = Command::new("ps").arg("-A").stdout(Stdio::piped()).output()?;
|
||||
let output = String::from_utf8_lossy(&output.stdout);
|
||||
|
||||
if !output.contains("BH3.exe") {
|
||||
if !output.contains("PGR.exe") {
|
||||
break;
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
if let Some(rpc) = &rpc {
|
||||
rpc.update(RpcUpdates::Update)?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
|
|
|
@ -246,6 +246,11 @@ pub fn run() -> anyhow::Result<()> {
|
|||
if !output.contains("StarRail.exe") {
|
||||
break;
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
if let Some(rpc) = &rpc {
|
||||
rpc.update(RpcUpdates::Update)?;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "discord-rpc")]
|
||||
|
|
Loading…
Reference in a new issue