Skip to main content

Crate mado

Crate mado 

Source
Expand description

§mado (窓)

macOS active app and window monitoring with browser metadata.

mado wraps native macOS APIs through Swift. Use it to query the active app and focused window, listen to focus changes, extract browser URL metadata, and scan installed apps from Rust.

§Quick Start

§Query current state

let app = mado::get_active_app()?;
println!("Current app: {}", app);

let window = mado::get_active_window()?;
println!("Window: {}", window);

§Monitor changes

use mado::{WindowListener, WindowMonitor, WindowEvent};

struct MyListener;

impl WindowListener for MyListener {
    fn on_focus_change(&self, event: WindowEvent) {
        match event {
            WindowEvent::AppActivated { app } => {
                println!("App: {}", app);
            }
            WindowEvent::WindowChanged { window } => {
                println!("Window: {}", window);
            }
        }
    }
}

let monitor = WindowMonitor::new(MyListener);
monitor.run()?;

§Platform Support

  • macOS: supported
  • Linux: planned
  • Windows: planned

§Requirements

macOS:

  • Accessibility permissions required if track_window_changes: true (default)

Re-exports§

pub use config::InstalledAppsConfig;
pub use config::MonitorConfig;
pub use config::QueryConfig;
pub use error::Error;
pub use listener::WindowListener;
pub use monitor::WindowMonitor;
pub use types::AppIcon;
pub use types::AppInfo;
pub use types::BrowserInfo;
pub use types::InstalledApp;
pub use types::WebsiteIcon;
pub use types::WebsiteInfo;
pub use types::WindowBounds;
pub use types::WindowEvent;
pub use types::WindowInfo;

Modules§

config
error
listener
monitor
platform
types

Functions§

get_active_app
Get information about the currently active application
get_active_app_with_config
Get information about the currently active application with custom configuration.
get_active_window
Get information about the currently active window.
get_active_window_with_config
Get information about the currently active window with custom configuration.
get_app_color
Get the display color for a specific app by bundle identifier.
get_app_icon
Get icon for a specific app by bundle identifier.
get_installed_apps
Get all installed applications on the system.
get_website_icon
Get favicon for a website URL.
is_accessibility_trusted
Check if accessibility permissions are granted (macOS only)