diff --git a/src/service.rs b/src/service.rs index b84c876..241ca59 100644 --- a/src/service.rs +++ b/src/service.rs @@ -40,12 +40,16 @@ pub fn install() -> anyhow::Result { } pub fn is_installed() -> anyhow::Result { - require_linux()?; + if !is_linux() { + return Ok(false); + } Ok(unit_path()?.exists()) } pub fn is_running() -> anyhow::Result { - require_linux()?; + if !is_linux() { + return Ok(false); + } Ok(Command::new("systemctl") .args(["--user", "is-active", "--quiet", UNIT_NAME]) .stdin(Stdio::null()) @@ -103,12 +107,16 @@ pub fn uninstall() -> anyhow::Result { } fn require_linux() -> anyhow::Result<()> { - if cfg!(target_os = "linux") { + if is_linux() { return Ok(()); } anyhow::bail!("Appa service commands are only supported on Linux with systemd") } +fn is_linux() -> bool { + cfg!(target_os = "linux") +} + fn unit_path() -> anyhow::Result { let config_directory = match env::var_os("XDG_CONFIG_HOME") { Some(path) => PathBuf::from(path),