feat(core): wire up status change notifications

This commit is contained in:
Federico Terzi 2021-10-31 21:08:21 +01:00
parent a806e180e1
commit 93cb9680e6
2 changed files with 18 additions and 2 deletions

View File

@ -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,
&notification_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);

View File

@ -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!")
}
}
}