Expand description
Types for communicating with niri via IPC.
After connecting to the niri socket, you can send a single Request
and receive a single
Reply
, which is a Result
wrapping a Response
. If you requested an event stream, you
can keep reading Event
s from the socket after the response.
You can use the socket::Socket
helper if you’re fine with blocking communication. However,
it is a fairly simple helper, so if you need async, or if you’re using a different language,
you are encouraged to communicate with the socket manually.
- Read the socket filesystem path from
socket::SOCKET_PATH_ENV
($NIRI_SOCKET
). - Connect to the socket and write a JSON-formatted
Request
on a single line. You can follow up with a line break and a flush, or just flush and shutdown the write end of the socket. - Niri will respond with a single line JSON-formatted
Reply
. - If you requested an event stream, niri will keep responding with JSON-formatted
Event
s, on a single line each.
§Backwards compatibility
This crate follows the niri version. It is not API-stable in terms of the Rust semver. In particular, expect new struct fields and enum variants to be added in patch version bumps.
Use an exact version requirement to avoid breaking changes:
[dependencies]
niri-ipc = "=0.1.10"
§Features
This crate defines the following features:
json-schema
: derives the schemarsJsonSchema
trait for the types.clap
: derives the clap CLI parsing traits for some types. Used internally by niri itself.
Modules§
- Helper for blocking communication over the niri socket.
- Helpers for keeping track of the event stream state.
Structs§
- Output mode as set in the config file.
- Output position as set in the config file.
- Configured keyboard layouts.
- A layer-shell surface.
- Logical output in the compositor’s coordinate space.
- Output mode.
- Connected output.
- Output VRR to set.
- Toplevel window.
- A workspace.
Enums§
- Actions that niri can perform.
- A compositor event.
- A layer-shell layer.
- Keyboard interactivity modes for a layer-shell surface.
- Layout to switch to.
- Output mode to set.
- Output actions that niri can perform.
- Output configuration change result.
- Output position to set.
- Request from client to niri.
- Successful response from niri to client.
- Output scale to set.
- Change in window or column size.
- Output transform, which goes counter-clockwise.
- Workspace reference (id, index or name) to operate on.
Type Aliases§
- Reply from niri to client.