From 948d6f12053d70085c2cd32252a35af9ebeb34e7 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Mon, 3 Aug 2026 01:38:40 -0400 Subject: [PATCH] Report absent systemd service off Linux --- src/service.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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), -- 2.51.2