diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-17 10:38:32 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-17 10:45:18 +0400 |
| commit | 40c85da102054caeb86b7905cd27c69e392c8f92 (patch) | |
| tree | ea0f2547ca2949d43ff5898ebab3a56d7eee6d1e /niri-ipc/src | |
| parent | 768b32602839896012a9ee3c4ed6885360fa5395 (diff) | |
| download | niri-40c85da102054caeb86b7905cd27c69e392c8f92.tar.gz niri-40c85da102054caeb86b7905cd27c69e392c8f92.tar.bz2 niri-40c85da102054caeb86b7905cd27c69e392c8f92.zip | |
Add an IPC socket and a niri msg outputs subcommand
Diffstat (limited to 'niri-ipc/src')
| -rw-r--r-- | niri-ipc/src/lib.rs | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs new file mode 100644 index 00000000..129e8f57 --- /dev/null +++ b/niri-ipc/src/lib.rs @@ -0,0 +1,55 @@ +//! Types for communicating with niri via IPC. +#![warn(missing_docs)] + +use std::collections::HashMap; + +use serde::{Deserialize, Serialize}; + +/// Name of the environment variable containing the niri IPC socket path. +pub const SOCKET_PATH_ENV: &str = "NIRI_SOCKET"; + +/// Request from client to niri. +#[derive(Debug, Serialize, Deserialize)] +pub enum Request { + /// Request information about connected outputs. + Outputs, +} + +/// Response from niri to client. +#[derive(Debug, Serialize, Deserialize)] +pub enum Response { + /// Information about connected outputs. + /// + /// Map from connector name to output info. + Outputs(HashMap<String, Output>), +} + +/// Connected output. +#[derive(Debug, Serialize, Deserialize, Clone)] +pub struct Output { + /// Name of the output. + pub name: String, + /// Textual description of the manufacturer. + pub make: String, + /// Textual description of the model. + pub model: String, + /// Physical width and height of the output in millimeters, if known. + pub physical_size: Option<(u32, u32)>, + /// Available modes for the output. + pub modes: Vec<Mode>, + /// Index of the current mode in [`Self::modes`]. + /// + /// `None` if the output is disabled. + pub current_mode: Option<usize>, +} + +/// Output mode. +#[derive(Debug, Serialize, Deserialize, Clone, Copy)] +pub struct Mode { + /// Width in physical pixels. + pub width: u16, + /// Height in physical pixels. + pub height: u16, + /// Refresh rate in millihertz. + pub refresh_rate: u32, +} |
