diff --git a/espanso/src/cli/daemon/mod.rs b/espanso/src/cli/daemon/mod.rs
index 631eec1..e212a45 100644
--- a/espanso/src/cli/daemon/mod.rs
+++ b/espanso/src/cli/daemon/mod.rs
@@ -42,7 +42,6 @@ use super::{CliModule, CliModuleArgs, PathsOverrides};
mod ipc;
mod troubleshoot;
-mod ui;
mod watcher;
pub fn new() -> CliModule {
@@ -62,9 +61,6 @@ fn daemon_main(args: CliModuleArgs) -> i32 {
let paths_overrides = args
.paths_overrides
.expect("missing paths_overrides in daemon main");
- let preferences =
- crate::preferences::get_default(&paths.runtime).expect("unable to obtain preferences");
- let cli_args = args.cli_args.expect("missing cli_args in daemon main");
// Make sure only one instance of the daemon is running
let lock_file = acquire_daemon_lock(&paths.runtime);
@@ -132,10 +128,6 @@ fn daemon_main(args: CliModuleArgs) -> i32 {
ipc::initialize_and_spawn(&paths.runtime, exit_notify.clone())
.expect("unable to initialize ipc server for daemon");
- if cli_args.is_present("show-welcome") {
- ui::show_welcome_screen(&preferences);
- }
-
loop {
select! {
recv(watcher_signal) -> _ => {
diff --git a/espanso/src/cli/launcher/daemon.rs b/espanso/src/cli/launcher/daemon.rs
index 0ea8697..f932ad8 100644
--- a/espanso/src/cli/launcher/daemon.rs
+++ b/espanso/src/cli/launcher/daemon.rs
@@ -25,14 +25,10 @@ use thiserror::Error;
use crate::cli::PathsOverrides;
use crate::cli::util::CommandExt;
-pub fn launch_daemon(paths_overrides: &PathsOverrides, show_welcome: bool) -> Result<()> {
+pub fn launch_daemon(paths_overrides: &PathsOverrides) -> Result<()> {
let espanso_exe_path = std::env::current_exe()?;
let mut command = Command::new(&espanso_exe_path.to_string_lossy().to_string());
- let mut args = vec!["daemon"];
- if show_welcome {
- args.push("--show-welcome");
- }
- command.args(&args);
+ command.args(&["daemon"]);
command.with_paths_overrides(paths_overrides);
let mut child = command.spawn()?;
diff --git a/espanso/src/cli/launcher/mod.rs b/espanso/src/cli/launcher/mod.rs
index a8234e0..11720da 100644
--- a/espanso/src/cli/launcher/mod.rs
+++ b/espanso/src/cli/launcher/mod.rs
@@ -64,7 +64,6 @@ fn launcher_main(args: CliModuleArgs) -> i32 {
let preferences =
crate::preferences::get_default(&paths.runtime).expect("unable to initialize preferences");
- let is_first_start = !preferences.has_completed_wizard();
let is_welcome_page_enabled = !preferences.has_completed_wizard();
@@ -184,7 +183,7 @@ fn launcher_main(args: CliModuleArgs) -> i32 {
espanso_mac_utils::convert_to_background_app();
}
- daemon::launch_daemon(&paths_overrides, is_first_start).expect("failed to launch daemon");
+ daemon::launch_daemon(&paths_overrides).expect("failed to launch daemon");
}
LAUNCHER_SUCCESS
diff --git a/espanso/src/cli/modulo/welcome.rs b/espanso/src/cli/modulo/welcome.rs
index 1a08c27..c8cb678 100644
--- a/espanso/src/cli/modulo/welcome.rs
+++ b/espanso/src/cli/modulo/welcome.rs
@@ -19,16 +19,13 @@
use clap::{ArgMatches};
use crate::icon::IconPaths;
-use crate::preferences::Preferences;
use espanso_modulo::welcome::*;
use espanso_path::Paths;
pub fn welcome_main(matches: &ArgMatches, paths: &Paths, icon_paths: &IconPaths) -> i32 {
- let preferences =
- crate::preferences::get_default(&paths.runtime).expect("unable to initialize preferences");
-
let dont_show_again_handler = Box::new(move |dont_show: bool| {
- preferences.set_should_display_welcome(!dont_show);
+ //preferences.set_should_display_welcome(!dont_show);
+ // TODO: this should probably be deleted if not used?
});
let is_already_running = matches.is_present("already-running");
diff --git a/espanso/src/cli/worker/engine/mod.rs b/espanso/src/cli/worker/engine/mod.rs
index bfe799f..a881a46 100644
--- a/espanso/src/cli/worker/engine/mod.rs
+++ b/espanso/src/cli/worker/engine/mod.rs
@@ -28,8 +28,7 @@ use espanso_path::Paths;
use espanso_ui::{event::UIEvent, UIRemote};
use log::{debug, error, info, warn};
-use crate::{
- cli::worker::{
+use crate::{cli::worker::{
engine::{
dispatch::executor::{
clipboard_injector::ClipboardInjectorAdapter, context_menu::ContextMenuHandlerAdapter,
@@ -52,9 +51,7 @@ use crate::{
},
},
match_cache::MatchCache,
- },
- engine::event::ExitMode,
-};
+ }, engine::event::ExitMode, preferences::Preferences};
use super::secure_input::SecureInputEvent;
@@ -79,6 +76,7 @@ pub fn initialize_and_spawn(
.name("engine thread".to_string())
.spawn(move || {
// TODO: properly order the initializations if necessary
+ let preferences = crate::preferences::get_default(&paths.runtime).expect("unable to load preferences");
let app_info_provider =
espanso_info::get_provider().expect("unable to initialize app info provider");
@@ -215,7 +213,14 @@ pub fn initialize_and_spawn(
// TODO: check config
match run_count {
- 0 => ui_remote.show_notification("Espanso is running!"),
+ 0 => {
+ ui_remote.show_notification("Espanso is running!");
+
+ if !preferences.has_displayed_welcome() {
+ super::ui::welcome::show_welcome_screen();
+ preferences.set_has_displayed_welcome(true);
+ }
+ },
n => {
if has_been_started_manually {
ui_remote.show_notification("Configuration reloaded!");
diff --git a/espanso/src/cli/worker/ui/mod.rs b/espanso/src/cli/worker/ui/mod.rs
index 8b9382c..f08a156 100644
--- a/espanso/src/cli/worker/ui/mod.rs
+++ b/espanso/src/cli/worker/ui/mod.rs
@@ -17,4 +17,5 @@
* along with espanso. If not, see .
*/
-pub mod util;
\ No newline at end of file
+pub mod util;
+pub mod welcome;
\ No newline at end of file
diff --git a/espanso/src/cli/daemon/ui.rs b/espanso/src/cli/worker/ui/welcome.rs
similarity index 60%
rename from espanso/src/cli/daemon/ui.rs
rename to espanso/src/cli/worker/ui/welcome.rs
index 9d0ff5a..d37c46e 100644
--- a/espanso/src/cli/daemon/ui.rs
+++ b/espanso/src/cli/worker/ui/welcome.rs
@@ -17,20 +17,16 @@
* along with espanso. If not, see .
*/
-use crate::preferences::Preferences;
-
#[cfg(feature = "modulo")]
-pub fn show_welcome_screen(preferences: &impl Preferences) {
- if preferences.should_display_welcome() {
- let espanso_exe_path = std::env::current_exe().expect("unable to determine executable path");
- let mut command = std::process::Command::new(&espanso_exe_path.to_string_lossy().to_string());
- command.args(&["modulo", "welcome"]);
+pub fn show_welcome_screen() {
+ let espanso_exe_path = std::env::current_exe().expect("unable to determine executable path");
+ let mut command = std::process::Command::new(&espanso_exe_path.to_string_lossy().to_string());
+ command.args(&["modulo", "welcome"]);
- command.spawn().expect("unable to show welcome screen");
- }
+ command.spawn().expect("unable to show welcome screen");
}
#[cfg(not(feature = "modulo"))]
-pub fn show_welcome_screen(_: &impl Preferences) {
- // NOOP
-}
\ No newline at end of file
+pub fn show_welcome_screen() {
+ // NOOP
+}
diff --git a/espanso/src/main.rs b/espanso/src/main.rs
index 6f664ca..9d9a951 100644
--- a/espanso/src/main.rs
+++ b/espanso/src/main.rs
@@ -192,12 +192,6 @@ fn main() {
.subcommand(
SubCommand::with_name("daemon")
.setting(AppSettings::Hidden)
- .arg(
- Arg::with_name("show-welcome")
- .long("show-welcome")
- .required(false)
- .takes_value(false),
- )
.about("Start the daemon without spawning a new process."),
)
// .subcommand(SubCommand::with_name("register")
diff --git a/espanso/src/preferences/default.rs b/espanso/src/preferences/default.rs
index b2516f3..1708e67 100644
--- a/espanso/src/preferences/default.rs
+++ b/espanso/src/preferences/default.rs
@@ -25,7 +25,7 @@ use anyhow::Result;
use super::Preferences;
const HAS_COMPLETED_WIZARD_KEY: &str = "has_completed_wizard";
-const SHOULD_DISPLAY_WELCOME_KEY: &str = "should_display_welcome";
+const HAS_DISPLAYED_WELCOME_KEY: &str = "has_displayed_welcome";
const SHOULD_DISPLAY_TROUBLESHOOT_FOR_NON_FATAL_ERRORS: &str =
"should_display_troubleshoot_for_non_fatal_errors";
@@ -64,12 +64,12 @@ impl Preferences for DefaultPreferences {
self.set(HAS_COMPLETED_WIZARD_KEY, value);
}
- fn should_display_welcome(&self) -> bool {
- self.get(SHOULD_DISPLAY_WELCOME_KEY).unwrap_or(true)
+ fn has_displayed_welcome(&self) -> bool {
+ self.get(HAS_DISPLAYED_WELCOME_KEY).unwrap_or(false)
}
- fn set_should_display_welcome(&self, value: bool) {
- self.set(SHOULD_DISPLAY_WELCOME_KEY, value);
+ fn set_has_displayed_welcome(&self, value: bool) {
+ self.set(HAS_DISPLAYED_WELCOME_KEY, value);
}
fn should_display_troubleshoot_for_non_fatal_errors(&self) -> bool {
diff --git a/espanso/src/preferences/mod.rs b/espanso/src/preferences/mod.rs
index e7aad17..8452546 100644
--- a/espanso/src/preferences/mod.rs
+++ b/espanso/src/preferences/mod.rs
@@ -26,8 +26,8 @@ pub trait Preferences: Send + Sync + Clone {
fn has_completed_wizard(&self) -> bool;
fn set_completed_wizard(&self, value: bool);
- fn should_display_welcome(&self) -> bool;
- fn set_should_display_welcome(&self, value: bool);
+ fn has_displayed_welcome(&self) -> bool;
+ fn set_has_displayed_welcome(&self, value: bool);
fn should_display_troubleshoot_for_non_fatal_errors(&self) -> bool;
fn set_should_display_troubleshoot_for_non_fatal_errors(&self, value: bool);