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
|
icon: String
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Update RPC connection with already set activity params
|
||||||
|
Update,
|
||||||
|
|
||||||
/// Clear RPC activity
|
/// Clear RPC activity
|
||||||
ClearActivity
|
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 => {
|
RpcUpdates::ClearActivity => {
|
||||||
if connected {
|
if connected {
|
||||||
client.clear_activity().expect("Failed to clear discord rpc activity");
|
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") {
|
if !output.contains("GenshinImpact.e") && !output.contains("YuanShen.exe") && !output.contains("unlocker.exe") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "discord-rpc")]
|
||||||
|
if let Some(rpc) = &rpc {
|
||||||
|
rpc.update(RpcUpdates::Update)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "discord-rpc")]
|
#[cfg(feature = "discord-rpc")]
|
||||||
|
|
|
@ -246,6 +246,11 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
if !output.contains("BH3.exe") {
|
if !output.contains("BH3.exe") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "discord-rpc")]
|
||||||
|
if let Some(rpc) = &rpc {
|
||||||
|
rpc.update(RpcUpdates::Update)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "discord-rpc")]
|
#[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 = Command::new("ps").arg("-A").stdout(Stdio::piped()).output()?;
|
||||||
let output = String::from_utf8_lossy(&output.stdout);
|
let output = String::from_utf8_lossy(&output.stdout);
|
||||||
|
|
||||||
if !output.contains("BH3.exe") {
|
if !output.contains("PGR.exe") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "discord-rpc")]
|
||||||
|
if let Some(rpc) = &rpc {
|
||||||
|
rpc.update(RpcUpdates::Update)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "discord-rpc")]
|
#[cfg(feature = "discord-rpc")]
|
||||||
|
|
|
@ -246,6 +246,11 @@ pub fn run() -> anyhow::Result<()> {
|
||||||
if !output.contains("StarRail.exe") {
|
if !output.contains("StarRail.exe") {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "discord-rpc")]
|
||||||
|
if let Some(rpc) = &rpc {
|
||||||
|
rpc.update(RpcUpdates::Update)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "discord-rpc")]
|
#[cfg(feature = "discord-rpc")]
|
||||||
|
|
Loading…
Reference in a new issue