diff --git a/espanso/src/cli/daemon/mod.rs b/espanso/src/cli/daemon/mod.rs
index 423bb22..1a7793b 100644
--- a/espanso/src/cli/daemon/mod.rs
+++ b/espanso/src/cli/daemon/mod.rs
@@ -27,14 +27,10 @@ use espanso_ipc::IPCClient;
use espanso_path::Paths;
use log::{error, info, warn};
-use crate::{
- exit_code::{
+use crate::{VERSION, exit_code::{
DAEMON_ALREADY_RUNNING, DAEMON_GENERAL_ERROR, DAEMON_LEGACY_ALREADY_RUNNING, DAEMON_SUCCESS,
WORKER_EXIT_ALL_PROCESSES, WORKER_RESTART, WORKER_SUCCESS,
- },
- ipc::{create_ipc_client_to_worker, IPCEvent},
- lock::{acquire_daemon_lock, acquire_legacy_lock, acquire_worker_lock},
-};
+ }, ipc::{create_ipc_client_to_worker, IPCEvent}, lock::{acquire_daemon_lock, acquire_legacy_lock, acquire_worker_lock}};
use super::{CliModule, CliModuleArgs};
@@ -54,8 +50,6 @@ pub fn new() -> CliModule {
}
}
-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
diff --git a/espanso/src/cli/launcher/mod.rs b/espanso/src/cli/launcher/mod.rs
index 351d973..e7754c1 100644
--- a/espanso/src/cli/launcher/mod.rs
+++ b/espanso/src/cli/launcher/mod.rs
@@ -17,8 +17,12 @@
* along with espanso. If not, see .
*/
+use espanso_modulo::wizard::{WizardHandlers, WizardOptions};
+
use super::{CliModule, CliModuleArgs};
+mod util;
+
// TODO: test also with modulo feature disabled
pub fn new() -> CliModule {
@@ -38,7 +42,37 @@ fn launcher_main(args: CliModuleArgs) -> i32 {
let cli_args = args.cli_args.expect("missing cli_args in launcher main");
let icon_paths = crate::icon::load_icon_paths(&paths.runtime).expect("unable to load icon paths");
- espanso_modulo::wizard::show();
+ // TODO: should move wizard to "init" subcommand?
+
+ let is_legacy_version_page_enabled = util::is_legacy_version_running(&paths.runtime);
+ let runtime_dir_clone = paths.runtime.clone();
+ let is_legacy_version_running_handler = Box::new(move || {
+ util::is_legacy_version_running(&runtime_dir_clone)
+ });
+
+ espanso_modulo::wizard::show(WizardOptions {
+ version: crate::VERSION.to_string(),
+ is_welcome_page_enabled: true, // TODO
+ is_move_bundle_page_enabled: false, // TODO
+ is_legacy_version_page_enabled,
+ is_migrate_page_enabled: true, // TODO,
+ is_add_path_page_enabled: true, // TODO
+ is_accessibility_page_enabled: true, // TODO
+ window_icon_path: icon_paths
+ .wizard_icon
+ .map(|path| path.to_string_lossy().to_string()),
+ accessibility_image_1_path: None,
+ accessibility_image_2_path: None,
+ handlers: WizardHandlers {
+ is_legacy_version_running: Some(is_legacy_version_running_handler),
+ backup_and_migrate: None,
+ add_to_path: None,
+ enable_accessibility: None,
+ is_accessibility_enabled: None,
+ },
+ });
+
+ // TODO: enable "Add to PATH" page only when NOT in portable mode
0
}
@@ -46,4 +80,4 @@ fn launcher_main(args: CliModuleArgs) -> i32 {
#[cfg(not(feature = "modulo"))]
fn launcher_main(_: CliModuleArgs) -> i32 {
// TODO: handle what happens here
-}
+}
\ No newline at end of file
diff --git a/espanso/src/cli/launcher/util.rs b/espanso/src/cli/launcher/util.rs
new file mode 100644
index 0000000..c842fd1
--- /dev/null
+++ b/espanso/src/cli/launcher/util.rs
@@ -0,0 +1,31 @@
+/*
+ * This file is part of espanso.
+ *
+ * Copyright (C) 2019-2021 Federico Terzi
+ *
+ * espanso is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * espanso is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with espanso. If not, see .
+ */
+
+use std::path::Path;
+
+use crate::lock::acquire_legacy_lock;
+
+pub fn is_legacy_version_running(runtime_path: &Path) -> bool {
+ let legacy_lock_file = acquire_legacy_lock(runtime_path);
+ if legacy_lock_file.is_none() {
+ true
+ } else {
+ false
+ }
+}
\ No newline at end of file
diff --git a/espanso/src/icon.rs b/espanso/src/icon.rs
index 70d17ed..82df635 100644
--- a/espanso/src/icon.rs
+++ b/espanso/src/icon.rs
@@ -42,6 +42,7 @@ const MAC_SYSTEM_DISABLED_BINARY: &[u8] = include_bytes!("res/macos/iconsystemdi
pub struct IconPaths {
pub form_icon: Option,
pub search_icon: Option,
+ pub wizard_icon: Option,
pub tray_icon_normal: Option,
pub tray_icon_disabled: Option,
@@ -55,6 +56,7 @@ pub fn load_icon_paths(runtime_dir: &Path) -> Result {
Ok(IconPaths {
form_icon: Some(extract_icon(WINDOWS_LOGO_ICO_BINARY, &runtime_dir.join("form.ico"))?),
search_icon: Some(extract_icon(ICON_BINARY, &runtime_dir.join("search.png"))?),
+ wizard_icon: Some(extract_icon(WINDOWS_LOGO_ICO_BINARY, &runtime_dir.join("wizard.ico"))?),
tray_icon_normal: Some(extract_icon(WINDOWS_NORMAL_DARK_ICO_BINARY, &runtime_dir.join("normal.ico"))?),
tray_icon_disabled: Some(extract_icon(WINDOWS_DISABLED_DARK_ICO_BINARY, &runtime_dir.join("disabled.ico"))?),
logo: Some(extract_icon(ICON_BINARY, &runtime_dir.join("icon.png"))?),
diff --git a/espanso/src/res/accessibility_1.png b/espanso/src/res/accessibility_1.png
new file mode 100644
index 0000000..b945688
Binary files /dev/null and b/espanso/src/res/accessibility_1.png differ
diff --git a/espanso/src/res/accessibility_2.png b/espanso/src/res/accessibility_2.png
new file mode 100644
index 0000000..fa11e84
Binary files /dev/null and b/espanso/src/res/accessibility_2.png differ