diff --git a/espanso/src/cli/worker/engine/mod.rs b/espanso/src/cli/worker/engine/mod.rs index 6dd1fd3..07c653a 100644 --- a/espanso/src/cli/worker/engine/mod.rs +++ b/espanso/src/cli/worker/engine/mod.rs @@ -212,6 +212,8 @@ pub fn initialize_and_spawn( let disable_options = process::middleware::disable::extract_disable_options(&*config_manager.default()); + let notification_manager = NotificationManager::new(&*ui_remote, default_config); + let mut processor = espanso_engine::process::default( &matchers, &config_manager, @@ -229,6 +231,7 @@ pub fn initialize_and_spawn( &config_manager, &modifier_state_store, &combined_match_cache, + ¬ification_manager, ); let event_injector = EventInjectorAdapter::new(&*injector, &config_manager); @@ -257,8 +260,6 @@ pub fn initialize_and_spawn( } } - let notification_manager = NotificationManager::new(&*ui_remote, default_config); - match start_reason.as_deref() { Some(flag) if flag == WORKER_START_REASON_CONFIG_CHANGED => { notification_manager.notify_config_reloaded(false); diff --git a/espanso/src/cli/worker/ui/notification.rs b/espanso/src/cli/worker/ui/notification.rs index c08f139..632e9cf 100644 --- a/espanso/src/cli/worker/ui/notification.rs +++ b/espanso/src/cli/worker/ui/notification.rs @@ -54,3 +54,18 @@ impl<'a> NotificationManager<'a> { self.notify("Updated keyboard layout!"); } } + +impl<'a> espanso_engine::process::NotificationManager for NotificationManager<'a> { + fn notify_status_change(&self, enabled: bool) { + // Don't notify the status change outside Linux for now + if !cfg!(target_os = "linux") { + return; + } + + if enabled { + self.notify("Espanso enabled!") + } else { + self.notify("Espanso disabled!") + } + } +}