From e3eecf05559557e0fdd85c61683c778f783ebe3b Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 5 May 2021 21:19:49 +0200 Subject: [PATCH] feat(core): implement active backend detection --- espanso/src/cli/worker/config.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/espanso/src/cli/worker/config.rs b/espanso/src/cli/worker/config.rs index 90462f2..85d34f5 100644 --- a/espanso/src/cli/worker/config.rs +++ b/espanso/src/cli/worker/config.rs @@ -104,9 +104,13 @@ impl<'a> ConfigProvider<'a> for ConfigManager<'a> { impl<'a> ModeProvider for ConfigManager<'a> { fn active_mode(&self) -> crate::engine::dispatch::Mode { - // TODO: implement the actual active mode detection starting from the active config - crate::engine::dispatch::Mode::Auto { - clipboard_threshold: 100 + let config = self.active(); + match config.backend() { + espanso_config::config::Backend::Inject => crate::engine::dispatch::Mode::Event, + espanso_config::config::Backend::Clipboard => crate::engine::dispatch::Mode::Clipboard, + espanso_config::config::Backend::Auto => crate::engine::dispatch::Mode::Auto { + clipboard_threshold: config.clipboard_threshold(), + }, } } }