pub struct Niri { /* private fields */ }Expand description
The niri service, from cx.niri(). A clone is cheap and shares the
one connection.
Implementations§
Source§impl Niri
impl Niri
Sourcepub fn workspaces(&self) -> ReadSignal<Vec<NiriWorkspace>>
pub fn workspaces(&self) -> ReadSignal<Vec<NiriWorkspace>>
Every workspace, by output name and then by idx. Empty while niri
isn’t connected.
Sourcepub fn windows(&self) -> ReadSignal<Vec<NiriWindow>>
pub fn windows(&self) -> ReadSignal<Vec<NiriWindow>>
Every window, by id. Empty while niri isn’t connected.
Sourcepub fn keyboard_layouts(&self) -> ReadSignal<Option<NiriKeyboardLayouts>>
pub fn keyboard_layouts(&self) -> ReadSignal<Option<NiriKeyboardLayouts>>
The keyboard layouts, once niri has said them.
Sourcepub fn overview_open(&self) -> ReadSignal<bool>
pub fn overview_open(&self) -> ReadSignal<bool>
Whether niri’s overview is open.
Sourcepub fn focus_workspace(&self, id: u64)
pub fn focus_workspace(&self, id: u64)
Switches to the workspace with the id id.
Sourcepub fn focus_window(&self, id: u64)
pub fn focus_window(&self, id: u64)
Focuses the window with the id id.
Sourcepub fn action(&self, action: Value)
pub fn action(&self, action: Value)
Sends niri {"Action": action}, as niri msg action does, on a
connection of its own, and never waits for it. action is one of
niri-ipc’s Actions in JSON, such as
json!({ "Spawn": { "command": ["foot"] } }). niri’s refusal is
logged, and so is an action over 8 KiB, or past 64 waiting for a
reply, which isn’t sent.
Sourcepub fn on_event(&self, handler: impl Fn(&Value) + 'static)
pub fn on_event(&self, handler: impl Fn(&Value) + 'static)
Calls handler with every event niri sends, as its JSON, such as
{"OverviewOpenedOrClosed":{"is_open":true}}, until the context
cx.niri() was called on goes. The lists have taken the event in
by then.
It runs on the main thread. If it panics, that is logged with the
event’s name and where on_event was called, and it isn’t called
again. Called on a handle whose context went, it logs that and does
nothing.