Skip to main content

list_apps/
list_apps.rs

1//! Lists running and installed apps.
2
3#![allow(clippy::print_stdout)]
4
5#[cfg(any(target_os = "macos", target_os = "windows", target_os = "linux"))]
6fn main() -> computer_use::Result<()> {
7    let computer = computer_use::Computer::new()?;
8    for app in computer.list_apps()? {
9        let status = match (app.is_running, app.is_active, app.needs_restart) {
10            (true, _, true) => "restart",
11            (true, true, _) => "active",
12            (true, false, _) => "running",
13            _ => "installed",
14        };
15        let pid = app.pid.map(|p| format!(" pid {p}")).unwrap_or_default();
16        println!("{:<9} {} [{}]{pid}", status, app.name, app.reference());
17    }
18    Ok(())
19}
20
21#[cfg(not(any(target_os = "macos", target_os = "windows", target_os = "linux")))]
22fn main() {}