From c79d248812f97bc2e8f865443b1feb580c690d31 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Thu, 3 Jun 2021 21:01:04 +0200 Subject: [PATCH] feat(core): wire up auto_restart option --- espanso/src/cli/daemon/mod.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/espanso/src/cli/daemon/mod.rs b/espanso/src/cli/daemon/mod.rs index 0d79189..03749d9 100644 --- a/espanso/src/cli/daemon/mod.rs +++ b/espanso/src/cli/daemon/mod.rs @@ -58,6 +58,9 @@ const VERSION: &str = env!("CARGO_PKG_VERSION"); fn daemon_main(args: CliModuleArgs) -> i32 { let paths = args.paths.expect("missing paths in daemon main"); + let config_store = args + .config_store + .expect("missing config store in worker main"); // Make sure only one instance of the daemon is running let lock_file = acquire_daemon_lock(&paths.runtime); @@ -92,9 +95,11 @@ fn daemon_main(args: CliModuleArgs) -> i32 { .expect("unable to initialize ipc server for daemon"); let (watcher_notify, watcher_signal) = unbounded::<()>(); - // TODO: check if "auto_restart" config option is enabled before starting it - watcher::initialize_and_spawn(&paths.config, watcher_notify) - .expect("unable to initialize config watcher thread"); + + if config_store.default().auto_restart() { + watcher::initialize_and_spawn(&paths.config, watcher_notify) + .expect("unable to initialize config watcher thread"); + } loop { select! {