Thanks to visit codestin.com
Credit goes to lib.rs

1 unstable release

Uses new Rust 2024

0.1.0 May 18, 2026

#9 in #niri

Codestin Search App Codestin Search App Codestin Search App

224 downloads per month

MIT and GPL-3.0-or-later

77KB
1K SLoC

Wayle

wayle-niri

Reactive bindings to the niri compositor via IPC.

Crates.io docs.rs License: MIT

cargo add wayle-niri

Usage

NiriService connects to niri's IPC socket (from $NIRI_SOCKET), subscribes to the event stream, and exposes the current window / workspace state through Property<T> fields.

use wayle_niri::NiriService;
use futures::StreamExt;

async fn example() -> wayle_niri::Result<()> {
    let service = NiriService::new().await?;

    for workspace in service.workspaces.get().values() {
        println!("workspace {} on {:?}", workspace.id.get(), workspace.output.get());
    }

    let mut focused = service.focused_window_id.watch();
    while let Some(window_id) = focused.next().await {
        println!("focused window id: {window_id:?}");
    }
    Ok(())
}

Actions

Send typed actions through the same service instance. action(Action) is the generic entry point; convenience wrappers cover the common cases.

use wayle_niri::{NiriService, WorkspaceReferenceArg};

async fn switch_and_spawn(service: &NiriService) -> wayle_niri::Result<()> {
    service.focus_workspace(WorkspaceReferenceArg::Index(2)).await?;
    service.spawn(vec!["alacritty".into()]).await?;
    Ok(())
}

License

MIT

Part of wayle-services.

Dependencies

~14–24MB
~393K SLoC