Tell orca to reload settings after we change them.

Use SIGUSR1 to tell orca to reload the settings we just wrote.
This commit is contained in:
Jeremy Whiting 2025-06-17 18:02:13 -06:00
parent da2585f2d7
commit 2508919d93

View file

@ -293,6 +293,7 @@ impl<'dbus> OrcaManager<'dbus> {
self.set_orca_option(PITCH_SETTING, pitch).await?;
self.pitch = pitch;
self.reload_orca().await?;
Ok(())
}
@ -305,6 +306,7 @@ impl<'dbus> OrcaManager<'dbus> {
self.set_orca_option(RATE_SETTING, rate).await?;
self.rate = rate;
self.reload_orca().await?;
Ok(())
}
@ -317,6 +319,7 @@ impl<'dbus> OrcaManager<'dbus> {
self.set_orca_option(VOLUME_SETTING, volume).await?;
self.volume = volume;
self.reload_orca().await?;
Ok(())
}
@ -423,6 +426,19 @@ impl<'dbus> OrcaManager<'dbus> {
Ok(())
}
#[cfg(test)]
async fn reload_orca(&self) -> Result<()> {
Ok(())
}
#[cfg(not(test))]
async fn reload_orca(&self) -> Result<()> {
// TODO: Use dbus api to tell orca to reload settings once dbus api is packaged.
let pid = self.get_orca_pid()?;
signal::kill(pid, signal::Signal::SIGUSR1)?;
Ok(())
}
fn get_orca_pid(&self) -> Result<Pid> {
let mut system = System::new();
system.refresh_all();