1 unstable release
Uses new Rust 2024
| 0.1.0 | May 18, 2026 |
|---|
#9 in #niri
224 downloads per month
77KB
1K
SLoC
wayle-niri
Reactive bindings to the niri compositor via IPC.
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