screenreader: Always try to start/stop orca in set_enabled

This commit is contained in:
Vicki Pfau 2025-06-18 18:59:08 -07:00
parent f62aa583e1
commit 84371fcc4e

View file

@ -146,21 +146,19 @@ impl<'dbus> OrcaManager<'dbus> {
} }
pub async fn set_enabled(&mut self, enable: bool) -> Result<()> { pub async fn set_enabled(&mut self, enable: bool) -> Result<()> {
if self.enabled == enable { if enable != self.enabled {
return Ok(()); #[cfg(not(test))]
} {
let a11ysettings = Settings::new(A11Y_SETTING);
#[cfg(not(test))] a11ysettings
{ .set_boolean(SCREEN_READER_SETTING, enable)
let a11ysettings = Settings::new(A11Y_SETTING); .map_err(|e| anyhow!("Unable to set screen reader enabled gsetting, {e}"))?;
a11ysettings }
.set_boolean(SCREEN_READER_SETTING, enable) if let Err(e) = self.set_orca_enabled(enable).await {
.map_err(|e| anyhow!("Unable to set screen reader enabled gsetting, {e}"))?; match e.downcast_ref::<std::io::Error>() {
} Some(e) if e.kind() == ErrorKind::NotFound => (),
if let Err(e) = self.set_orca_enabled(enable).await { _ => return Err(e),
match e.downcast_ref::<std::io::Error>() { }
Some(e) if e.kind() == ErrorKind::NotFound => (),
_ => return Err(e),
} }
} }
if enable { if enable {