diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ipc/client.rs | 8 | ||||
| -rw-r--r-- | src/ipc/server.rs | 11 | ||||
| -rw-r--r-- | src/main.rs | 1 | ||||
| -rw-r--r-- | src/ui/config_error_notification.rs | 5 | ||||
| -rw-r--r-- | src/utils/watcher.rs | 17 |
5 files changed, 37 insertions, 5 deletions
diff --git a/src/ipc/client.rs b/src/ipc/client.rs index 42fbbf75..094bb636 100644 --- a/src/ipc/client.rs +++ b/src/ipc/client.rs @@ -459,6 +459,14 @@ pub fn handle_msg(msg: Msg, json: bool) -> anyhow::Result<()> { Event::OverviewOpenedOrClosed { is_open: opened } => { println!("Overview toggled: {opened}"); } + Event::ConfigLoaded { failed } => { + let status = if failed { + "with an error" + } else { + "successfully" + }; + println!("Config loaded {status}"); + } } } } diff --git a/src/ipc/server.rs b/src/ipc/server.rs index 464a2a13..051bccab 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -762,4 +762,15 @@ impl State { state.apply(event.clone()); server.send_event(event); } + + pub fn ipc_config_loaded(&mut self, failed: bool) { + let Some(server) = &self.niri.ipc_server else { + return; + }; + let mut state = server.event_stream_state.borrow_mut(); + + let event = Event::ConfigLoaded { failed }; + state.apply(event.clone()); + server.send_event(event); + } } diff --git a/src/main.rs b/src/main.rs index 2b3e1c5a..9654f7e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -241,6 +241,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { // Show the config error notification right away if needed. if config_errored { state.niri.config_error_notification.show(); + state.ipc_config_loaded(true); } else if let Some(path) = config_created_at { state.niri.config_error_notification.show_created(path); } diff --git a/src/ui/config_error_notification.rs b/src/ui/config_error_notification.rs index 4e976633..20667172 100644 --- a/src/ui/config_error_notification.rs +++ b/src/ui/config_error_notification.rs @@ -78,6 +78,11 @@ impl ConfigErrorNotification { } pub fn show(&mut self) { + let c = self.config.borrow(); + if c.config_notification.disable_failed { + return; + } + if self.created_path.is_some() { self.created_path = None; self.buffers.borrow_mut().clear(); diff --git a/src/utils/watcher.rs b/src/utils/watcher.rs index 4ed4c8ae..034e963a 100644 --- a/src/utils/watcher.rs +++ b/src/utils/watcher.rs @@ -5,7 +5,7 @@ use std::sync::mpsc; use std::time::{Duration, SystemTime}; use std::{io, thread}; -use niri_config::ConfigPath; +use niri_config::{Config, ConfigPath}; use smithay::reexports::calloop::channel::SyncSender; use crate::niri::State; @@ -137,10 +137,17 @@ pub fn setup(state: &mut State, config_path: &ConfigPath) { state .niri .event_loop - .insert_source(rx, |event, _, state| match event { - calloop::channel::Event::Msg(config) => state.reload_config(config), - calloop::channel::Event::Closed => (), - }) + .insert_source( + rx, + |event: calloop::channel::Event<Result<Config, ()>>, _, state| match event { + calloop::channel::Event::Msg(config) => { + let failed = config.is_err(); + state.reload_config(config); + state.ipc_config_loaded(failed); + } + calloop::channel::Event::Closed => (), + }, + ) .unwrap(); state.niri.config_file_watcher = Some(Watcher::new(config_path.clone(), process, tx)); |
