diff options
| author | Horu <73709188+HigherOrderLogic@users.noreply.github.com> | 2025-08-17 16:28:24 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-17 09:28:24 +0300 |
| commit | 271534e115e5915231c99df287bbfe396185924d (patch) | |
| tree | 5642ba961a88d5f5d1f5afc0686d7b2f2476f28c /niri-ipc/src | |
| parent | af30cc8df68b29973c8b9eec290f9e6b93463929 (diff) | |
| download | niri-271534e115e5915231c99df287bbfe396185924d.tar.gz niri-271534e115e5915231c99df287bbfe396185924d.tar.bz2 niri-271534e115e5915231c99df287bbfe396185924d.zip | |
Add ConfigLoaded event to IPC, option to disable built-in notification (#1829)
* feat: config reload ipc event
* cleanups
* Rename and move the new config option
* rename to ConfigLoaded and emit at connection
---------
Co-authored-by: Ivan Molodetskikh <yalterz@gmail.com>
Diffstat (limited to 'niri-ipc/src')
| -rw-r--r-- | niri-ipc/src/lib.rs | 10 | ||||
| -rw-r--r-- | niri-ipc/src/state.rs | 30 |
2 files changed, 40 insertions, 0 deletions
diff --git a/niri-ipc/src/lib.rs b/niri-ipc/src/lib.rs index 737f1647..a1be86d2 100644 --- a/niri-ipc/src/lib.rs +++ b/niri-ipc/src/lib.rs @@ -1399,6 +1399,16 @@ pub enum Event { /// The new state of the overview. is_open: bool, }, + /// The configuration was reloaded. + /// + /// You will always receive this event when connecting to the event stream, indicating the last + /// config load attempt. + ConfigLoaded { + /// Whether the loading failed. + /// + /// For example, the config file couldn't be parsed. + failed: bool, + }, } impl FromStr for WorkspaceReferenceArg { diff --git a/niri-ipc/src/state.rs b/niri-ipc/src/state.rs index ef883021..3ba63a52 100644 --- a/niri-ipc/src/state.rs +++ b/niri-ipc/src/state.rs @@ -43,6 +43,9 @@ pub struct EventStreamState { /// State of the overview. pub overview: OverviewState, + + /// State of the config. + pub config: ConfigState, } /// The workspaces state communicated over the event stream. @@ -73,6 +76,13 @@ pub struct OverviewState { pub is_open: bool, } +/// The config state communicated over the event stream. +#[derive(Debug, Default)] +pub struct ConfigState { + /// Whether the last config load attempt had failed. + pub failed: bool, +} + impl EventStreamStatePart for EventStreamState { fn replicate(&self) -> Vec<Event> { let mut events = Vec::new(); @@ -80,6 +90,7 @@ impl EventStreamStatePart for EventStreamState { events.extend(self.windows.replicate()); events.extend(self.keyboard_layouts.replicate()); events.extend(self.overview.replicate()); + events.extend(self.config.replicate()); events } @@ -88,6 +99,7 @@ impl EventStreamStatePart for EventStreamState { let event = self.windows.apply(event)?; let event = self.keyboard_layouts.apply(event)?; let event = self.overview.apply(event)?; + let event = self.config.apply(event)?; Some(event) } } @@ -244,3 +256,21 @@ impl EventStreamStatePart for OverviewState { None } } + +impl EventStreamStatePart for ConfigState { + fn replicate(&self) -> Vec<Event> { + vec![Event::ConfigLoaded { + failed: self.failed, + }] + } + + fn apply(&mut self, event: Event) -> Option<Event> { + match event { + Event::ConfigLoaded { failed } => { + self.failed = failed; + } + event => return Some(event), + } + None + } +} |
