From 9e3742f273916880c30312d201b2424daf86acb2 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Wed, 6 Oct 2021 18:36:23 +0200 Subject: [PATCH] style(core): fix formatting --- espanso/src/capabilities/linux.rs | 4 +- espanso/src/capabilities/mod.rs | 1 - .../src/cli/daemon/keyboard_layout_watcher.rs | 2 +- espanso/src/cli/daemon/mod.rs | 19 +--- espanso/src/cli/daemon/troubleshoot.rs | 8 +- espanso/src/cli/daemon/watcher.rs | 6 +- espanso/src/cli/launcher/accessibility.rs | 2 +- espanso/src/cli/launcher/daemon.rs | 2 +- espanso/src/cli/launcher/mod.rs | 13 ++- espanso/src/cli/launcher/util.rs | 11 ++- espanso/src/cli/log.rs | 2 +- espanso/src/cli/migrate.rs | 19 +++- espanso/src/cli/mod.rs | 12 +-- espanso/src/cli/modulo/form.rs | 11 ++- espanso/src/cli/modulo/mod.rs | 6 +- espanso/src/cli/modulo/search.rs | 11 ++- espanso/src/cli/modulo/troubleshoot.rs | 99 ++++++++++--------- espanso/src/cli/modulo/welcome.rs | 4 +- espanso/src/cli/package/install.rs | 8 +- espanso/src/cli/package/list.rs | 11 ++- espanso/src/cli/package/uninstall.rs | 4 +- espanso/src/cli/path.rs | 24 ++++- espanso/src/cli/service/linux.rs | 23 +++-- espanso/src/cli/service/mod.rs | 12 ++- espanso/src/cli/service/unix.rs | 2 +- espanso/src/cli/service/win.rs | 24 +++-- espanso/src/cli/workaround/mod.rs | 2 +- espanso/src/cli/workaround/secure_input.rs | 6 +- espanso/src/cli/worker/builtin/process.rs | 10 +- espanso/src/cli/worker/config.rs | 7 +- espanso/src/cli/worker/context/mod.rs | 4 +- .../worker/engine/caches/app_info_provider.rs | 9 +- espanso/src/cli/worker/engine/caches/mod.rs | 2 +- .../dispatch/executor/clipboard_injector.rs | 2 +- .../engine/dispatch/executor/context_menu.rs | 2 +- .../worker/engine/dispatch/executor/icon.rs | 8 +- .../worker/engine/dispatch/executor/mod.rs | 2 +- espanso/src/cli/worker/engine/dispatch/mod.rs | 2 +- .../src/cli/worker/engine/funnel/detect.rs | 4 +- espanso/src/cli/worker/engine/funnel/exit.rs | 9 +- espanso/src/cli/worker/engine/mod.rs | 53 +++++++--- .../engine/process/middleware/match_select.rs | 2 +- .../process/middleware/matcher/convert.rs | 4 +- .../worker/engine/process/middleware/mod.rs | 4 +- .../middleware/render/extension/clipboard.rs | 6 +- .../middleware/render/extension/mod.rs | 2 +- .../engine/process/middleware/render/mod.rs | 4 +- espanso/src/cli/worker/engine/process/mod.rs | 2 +- espanso/src/cli/worker/match_cache.rs | 2 +- espanso/src/cli/worker/ui/mod.rs | 2 +- espanso/src/cli/worker/ui/util.rs | 7 +- espanso/src/common_flags.rs | 2 +- espanso/src/gui/mod.rs | 10 +- espanso/src/gui/modulo/form.rs | 10 +- espanso/src/gui/modulo/manager.rs | 16 ++- espanso/src/gui/modulo/mod.rs | 2 +- espanso/src/gui/modulo/search.rs | 25 +++-- espanso/src/icon.rs | 68 ++++++++++--- espanso/src/ipc.rs | 12 +-- espanso/src/lock.rs | 8 +- espanso/src/logging/mod.rs | 24 ++--- espanso/src/main.rs | 5 +- espanso/src/patch/mod.rs | 2 +- .../patches/linux/alacritty_terminal_x11.rs | 2 +- espanso/src/patch/patches/linux/emacs_x11.rs | 2 +- .../patches/linux/generic_terminal_x11.rs | 2 +- .../patch/patches/linux/kitty_terminal_x11.rs | 2 +- .../patches/linux/konsole_terminal_x11.rs | 2 +- .../patches/linux/libreoffice_writer_x11.rs | 2 +- espanso/src/patch/patches/linux/mod.rs | 4 +- .../patches/linux/simple_terminal_2_x11.rs | 2 +- .../patches/linux/simple_terminal_x11.rs | 2 +- .../patches/linux/terminator_terminal_x11.rs | 2 +- .../patches/linux/termite_terminal_x11.rs | 2 +- .../patch/patches/linux/tilix_terminal_x11.rs | 2 +- .../patch/patches/linux/urxvt_terminal_x11.rs | 2 +- espanso/src/patch/patches/linux/util.rs | 2 +- .../patches/linux/yakuake_terminal_x11.rs | 2 +- espanso/src/patch/patches/macros.rs | 2 +- espanso/src/patch/patches/mod.rs | 2 +- espanso/src/patch/patches/win/mod.rs | 2 +- .../patches/win/onenote_for_windows_10.rs | 2 +- espanso/src/patch/patches/win/vscode_win.rs | 2 +- espanso/src/path/linux.rs | 2 +- espanso/src/path/macos.rs | 20 ++-- espanso/src/path/mod.rs | 12 +-- espanso/src/preferences/default.rs | 4 +- espanso/src/preferences/mod.rs | 4 +- espanso/src/util.rs | 2 +- 89 files changed, 439 insertions(+), 328 deletions(-) diff --git a/espanso/src/capabilities/linux.rs b/espanso/src/capabilities/linux.rs index 8a7a1db..5a4970e 100644 --- a/espanso/src/capabilities/linux.rs +++ b/espanso/src/capabilities/linux.rs @@ -26,7 +26,7 @@ pub fn can_use_capabilities() -> bool { Err(err) => { error!("error while checking if capabilities are enabled: {}", err); false - }, + } } } @@ -39,4 +39,4 @@ pub fn clear_capabilities() -> Result<()> { caps::clear(None, CapSet::Effective)?; caps::clear(None, CapSet::Permitted)?; Ok(()) -} \ No newline at end of file +} diff --git a/espanso/src/capabilities/mod.rs b/espanso/src/capabilities/mod.rs index 5204961..f407bb6 100644 --- a/espanso/src/capabilities/mod.rs +++ b/espanso/src/capabilities/mod.rs @@ -26,4 +26,3 @@ pub use linux::*; mod fallback; #[cfg(not(target_os = "linux"))] pub use fallback::*; - diff --git a/espanso/src/cli/daemon/keyboard_layout_watcher.rs b/espanso/src/cli/daemon/keyboard_layout_watcher.rs index 9224352..8f77892 100644 --- a/espanso/src/cli/daemon/keyboard_layout_watcher.rs +++ b/espanso/src/cli/daemon/keyboard_layout_watcher.rs @@ -19,7 +19,7 @@ use anyhow::Result; use crossbeam::channel::Sender; -use log::{error, debug}; +use log::{debug, error}; const WATCHER_INTERVAL: u64 = 1000; diff --git a/espanso/src/cli/daemon/mod.rs b/espanso/src/cli/daemon/mod.rs index 5eed349..7d7e95f 100644 --- a/espanso/src/cli/daemon/mod.rs +++ b/espanso/src/cli/daemon/mod.rs @@ -29,7 +29,7 @@ use log::{error, info, warn}; use crate::{ cli::util::CommandExt, - common_flags::{*}, + common_flags::*, exit_code::{ DAEMON_ALREADY_RUNNING, DAEMON_FATAL_CONFIG_ERROR, DAEMON_GENERAL_ERROR, DAEMON_LEGACY_ALREADY_RUNNING, DAEMON_SUCCESS, WORKER_EXIT_ALL_PROCESSES, WORKER_RESTART, @@ -123,11 +123,7 @@ fn daemon_main(args: CliModuleArgs) -> i32 { // TODO: register signals to terminate the worker if the daemon terminates - spawn_worker( - &paths_overrides, - exit_notify.clone(), - None - ); + spawn_worker(&paths_overrides, exit_notify.clone(), None); ipc::initialize_and_spawn(&paths.runtime, exit_notify.clone()) .expect("unable to initialize ipc server for daemon"); @@ -246,10 +242,7 @@ fn spawn_worker( let mut command = Command::new(&espanso_exe_path.to_string_lossy().to_string()); - let mut args = vec![ - "worker", - "--monitor-daemon", - ]; + let mut args = vec!["worker", "--monitor-daemon"]; if let Some(start_reason) = &start_reason { args.push("--start-reason"); args.push(start_reason); @@ -312,11 +305,7 @@ fn restart_worker( } if !has_timed_out { - spawn_worker( - paths_overrides, - exit_notify, - start_reason, - ); + spawn_worker(paths_overrides, exit_notify, start_reason); } else { error!("could not restart worker, as the exit process has timed out"); } diff --git a/espanso/src/cli/daemon/troubleshoot.rs b/espanso/src/cli/daemon/troubleshoot.rs index 55415d7..d33a4e3 100644 --- a/espanso/src/cli/daemon/troubleshoot.rs +++ b/espanso/src/cli/daemon/troubleshoot.rs @@ -99,11 +99,9 @@ pub fn load_config_or_troubleshoot(paths: &Paths, paths_overrides: &PathsOverrid LoadResult::Warning(load_result, troubleshoot_handle) } } - Err(_) => { - LoadResult::Fatal( - launch_troubleshoot(paths_overrides).expect("unable to launch troubleshoot GUI"), - ) - } + Err(_) => LoadResult::Fatal( + launch_troubleshoot(paths_overrides).expect("unable to launch troubleshoot GUI"), + ), } } diff --git a/espanso/src/cli/daemon/watcher.rs b/espanso/src/cli/daemon/watcher.rs index 34358d7..9bf817a 100644 --- a/espanso/src/cli/daemon/watcher.rs +++ b/espanso/src/cli/daemon/watcher.rs @@ -78,9 +78,9 @@ fn watcher_main(config_dir: &Path, watcher_notify: &Sender<()>) { if ["yml", "yaml"].iter().any(|ext| ext == &extension) { // Only load non-hidden yml files !is_file_hidden(&path) - } else { - // If there is no extension, it's probably a folder - extension.is_empty() + } else { + // If there is no extension, it's probably a folder + extension.is_empty() } } else { false diff --git a/espanso/src/cli/launcher/accessibility.rs b/espanso/src/cli/launcher/accessibility.rs index faaad80..a5c078f 100644 --- a/espanso/src/cli/launcher/accessibility.rs +++ b/espanso/src/cli/launcher/accessibility.rs @@ -35,4 +35,4 @@ pub fn is_accessibility_enabled() -> bool { #[cfg(target_os = "macos")] pub fn prompt_enable_accessibility() -> bool { espanso_mac_utils::prompt_accessibility() -} \ No newline at end of file +} diff --git a/espanso/src/cli/launcher/daemon.rs b/espanso/src/cli/launcher/daemon.rs index f932ad8..ee109da 100644 --- a/espanso/src/cli/launcher/daemon.rs +++ b/espanso/src/cli/launcher/daemon.rs @@ -22,8 +22,8 @@ use std::process::Command; use anyhow::Result; use thiserror::Error; -use crate::cli::PathsOverrides; use crate::cli::util::CommandExt; +use crate::cli::PathsOverrides; pub fn launch_daemon(paths_overrides: &PathsOverrides) -> Result<()> { let espanso_exe_path = std::env::current_exe()?; diff --git a/espanso/src/cli/launcher/mod.rs b/espanso/src/cli/launcher/mod.rs index 4c9d63b..dd6f0db 100644 --- a/espanso/src/cli/launcher/mod.rs +++ b/espanso/src/cli/launcher/mod.rs @@ -18,8 +18,11 @@ */ use self::util::MigrationError; -use crate::{exit_code::{LAUNCHER_ALREADY_RUNNING, LAUNCHER_CONFIG_DIR_POPULATION_FAILURE, LAUNCHER_SUCCESS}, lock::acquire_daemon_lock}; use crate::preferences::Preferences; +use crate::{ + exit_code::{LAUNCHER_ALREADY_RUNNING, LAUNCHER_CONFIG_DIR_POPULATION_FAILURE, LAUNCHER_SUCCESS}, + lock::acquire_daemon_lock, +}; use log::error; use super::{CliModule, CliModuleArgs}; @@ -75,8 +78,9 @@ fn launcher_main(args: CliModuleArgs) -> i32 { let runtime_dir_clone = paths.runtime.clone(); let is_legacy_version_running_handler = Box::new(move || util::is_legacy_version_running(&runtime_dir_clone)); - - let (is_wrong_edition_page_enabled, wrong_edition_detected_os) = edition_check::is_wrong_edition(); + + let (is_wrong_edition_page_enabled, wrong_edition_detected_os) = + edition_check::is_wrong_edition(); let is_migrate_page_enabled = espanso_config::is_legacy_config(&paths.config); let paths_clone = paths.clone(); @@ -115,8 +119,7 @@ fn launcher_main(args: CliModuleArgs) -> i32 { } else { false }; - let is_accessibility_enabled_handler = - Box::new(accessibility::is_accessibility_enabled); + let is_accessibility_enabled_handler = Box::new(accessibility::is_accessibility_enabled); let enable_accessibility_handler = Box::new(move || { accessibility::prompt_enable_accessibility(); }); diff --git a/espanso/src/cli/launcher/util.rs b/espanso/src/cli/launcher/util.rs index 4e04093..3a93e0c 100644 --- a/espanso/src/cli/launcher/util.rs +++ b/espanso/src/cli/launcher/util.rs @@ -20,10 +20,13 @@ use std::{path::Path, process::Command}; use anyhow::Result; -use thiserror::Error; use espanso_path::Paths; +use thiserror::Error; -use crate::{exit_code::{MIGRATE_CLEAN_FAILURE, MIGRATE_DIRTY_FAILURE}, lock::acquire_legacy_lock}; +use crate::{ + exit_code::{MIGRATE_CLEAN_FAILURE, MIGRATE_DIRTY_FAILURE}, + lock::acquire_legacy_lock, +}; pub fn is_legacy_version_running(runtime_path: &Path) -> bool { let legacy_lock_file = acquire_legacy_lock(runtime_path); @@ -55,8 +58,8 @@ pub fn migrate_configuration(paths: &Paths) -> Result<()> { } else { match result.code() { Some(code) if code == MIGRATE_CLEAN_FAILURE => Err(MigrationError::Clean.into()), - Some(code) if code == MIGRATE_DIRTY_FAILURE=> Err(MigrationError::Dirty.into()), - _ => Err(MigrationError::Unexpected.into()) + Some(code) if code == MIGRATE_DIRTY_FAILURE => Err(MigrationError::Dirty.into()), + _ => Err(MigrationError::Unexpected.into()), } } } diff --git a/espanso/src/cli/log.rs b/espanso/src/cli/log.rs index d900b83..93b6bce 100644 --- a/espanso/src/cli/log.rs +++ b/espanso/src/cli/log.rs @@ -17,8 +17,8 @@ * along with espanso. If not, see . */ -use std::{fs::File, io::BufReader}; use std::io::BufRead; +use std::{fs::File, io::BufReader}; use super::{CliModule, CliModuleArgs}; diff --git a/espanso/src/cli/migrate.rs b/espanso/src/cli/migrate.rs index c13e538..22ddb8f 100644 --- a/espanso/src/cli/migrate.rs +++ b/espanso/src/cli/migrate.rs @@ -17,9 +17,16 @@ * along with espanso. If not, see . */ -use std::{path::PathBuf}; +use std::path::PathBuf; -use crate::{exit_code::{MIGRATE_ALREADY_NEW_FORMAT, MIGRATE_CLEAN_FAILURE, MIGRATE_DIRTY_FAILURE, MIGRATE_LEGACY_INSTANCE_RUNNING, MIGRATE_SUCCESS, MIGRATE_USER_ABORTED, configure_custom_panic_hook, update_panic_exit_code}, lock::acquire_legacy_lock}; +use crate::{ + exit_code::{ + configure_custom_panic_hook, update_panic_exit_code, MIGRATE_ALREADY_NEW_FORMAT, + MIGRATE_CLEAN_FAILURE, MIGRATE_DIRTY_FAILURE, MIGRATE_LEGACY_INSTANCE_RUNNING, MIGRATE_SUCCESS, + MIGRATE_USER_ABORTED, + }, + lock::acquire_legacy_lock, +}; use super::{CliModule, CliModuleArgs}; use colored::*; @@ -91,11 +98,13 @@ fn migrate_main(args: CliModuleArgs) -> i32 { target_backup_dir.to_string_lossy() ); - if !cli_args.is_present("noconfirm") && !Confirm::new() + if !cli_args.is_present("noconfirm") + && !Confirm::new() .with_prompt("Do you want to proceed?") .default(true) .interact() - .expect("unable to read choice") { + .expect("unable to read choice") + { return MIGRATE_USER_ABORTED; } @@ -132,7 +141,7 @@ fn migrate_main(args: CliModuleArgs) -> i32 { fs_extra::dir::get_dir_content(&paths.config).expect("unable to list legacy dir files"); to_be_removed.extend(legacy_dir_content.files); to_be_removed.extend(legacy_dir_content.directories); - + // Skip the config directory itself to preserve the symbolic link (if present) let config_dir_as_str = paths.config.to_string_lossy().to_string(); to_be_removed.retain(|path| path != &config_dir_as_str); diff --git a/espanso/src/cli/mod.rs b/espanso/src/cli/mod.rs index fba2bd8..64ccff6 100644 --- a/espanso/src/cli/mod.rs +++ b/espanso/src/cli/mod.rs @@ -45,7 +45,7 @@ pub struct CliModule { pub subcommand: String, pub show_in_dock: bool, pub requires_linux_capabilities: bool, - pub entry: fn(CliModuleArgs)->i32, + pub entry: fn(CliModuleArgs) -> i32, } impl Default for CliModule { @@ -54,12 +54,12 @@ impl Default for CliModule { enable_logs: false, log_mode: LogMode::Read, disable_logs_terminal_output: false, - requires_paths: false, - requires_config: false, - subcommand: "".to_string(), + requires_paths: false, + requires_config: false, + subcommand: "".to_string(), show_in_dock: false, requires_linux_capabilities: false, - entry: |_| {0}, + entry: |_| 0, } } } @@ -104,4 +104,4 @@ pub struct PathsOverrides { pub struct CliAlias { pub subcommand: String, pub forward_into: String, -} \ No newline at end of file +} diff --git a/espanso/src/cli/modulo/form.rs b/espanso/src/cli/modulo/form.rs index 8124d30..73e6a4f 100644 --- a/espanso/src/cli/modulo/form.rs +++ b/espanso/src/cli/modulo/form.rs @@ -17,9 +17,9 @@ * along with espanso. If not, see . */ -use clap::{ArgMatches}; -use espanso_modulo::form::*; use crate::icon::IconPaths; +use clap::ArgMatches; +use espanso_modulo::form::*; pub fn form_main(matches: &ArgMatches, _icon_paths: &IconPaths) -> i32 { let as_json: bool = matches.is_present("json"); @@ -43,9 +43,12 @@ pub fn form_main(matches: &ArgMatches, _icon_paths: &IconPaths) -> i32 { } else { serde_json::from_str(&data).expect("unable to parse form configuration") }; - + // Overwrite the icon - config.icon = _icon_paths.form_icon.as_deref().map(|path| path.to_string_lossy().to_string()); + config.icon = _icon_paths + .form_icon + .as_deref() + .map(|path| path.to_string_lossy().to_string()); let form = generator::generate(config); let values = show(form); diff --git a/espanso/src/cli/modulo/mod.rs b/espanso/src/cli/modulo/mod.rs index 928a0a1..7954d50 100644 --- a/espanso/src/cli/modulo/mod.rs +++ b/espanso/src/cli/modulo/mod.rs @@ -24,9 +24,9 @@ mod form; #[cfg(feature = "modulo")] mod search; #[cfg(feature = "modulo")] -mod welcome; -#[cfg(feature = "modulo")] mod troubleshoot; +#[cfg(feature = "modulo")] +mod welcome; pub fn new() -> CliModule { #[allow(clippy::needless_update)] @@ -56,7 +56,7 @@ fn modulo_main(args: CliModuleArgs) -> i32 { if let Some(matches) = cli_args.subcommand_matches("welcome") { return welcome::welcome_main(matches, &paths, &icon_paths); } - + if cli_args.subcommand_matches("troubleshoot").is_some() { return troubleshoot::troubleshoot_main(&paths, &icon_paths); } diff --git a/espanso/src/cli/modulo/search.rs b/espanso/src/cli/modulo/search.rs index 853a934..a8d7f51 100644 --- a/espanso/src/cli/modulo/search.rs +++ b/espanso/src/cli/modulo/search.rs @@ -17,10 +17,10 @@ * along with espanso. If not, see . */ -use std::collections::HashMap; -use clap::{ArgMatches}; -use espanso_modulo::search::*; use crate::icon::IconPaths; +use clap::ArgMatches; +use espanso_modulo::search::*; +use std::collections::HashMap; pub fn search_main(matches: &ArgMatches, icon_paths: &IconPaths) -> i32 { let as_json: bool = matches.is_present("json"); @@ -46,7 +46,10 @@ pub fn search_main(matches: &ArgMatches, icon_paths: &IconPaths) -> i32 { }; // Overwrite the icon - config.icon = icon_paths.logo.as_deref().map(|path| path.to_string_lossy().to_string()); + config.icon = icon_paths + .logo + .as_deref() + .map(|path| path.to_string_lossy().to_string()); let algorithm = algorithm::get_algorithm(&config.algorithm, true); diff --git a/espanso/src/cli/modulo/troubleshoot.rs b/espanso/src/cli/modulo/troubleshoot.rs index 38bc5ad..5a6f262 100644 --- a/espanso/src/cli/modulo/troubleshoot.rs +++ b/espanso/src/cli/modulo/troubleshoot.rs @@ -17,7 +17,7 @@ * along with espanso. If not, see . */ -use std::path::{Path}; +use std::path::Path; use crate::icon::IconPaths; use crate::preferences::Preferences; @@ -38,68 +38,69 @@ pub fn troubleshoot_main(paths: &Paths, icon_paths: &IconPaths) -> i32 { } }); - let (is_fatal_error, error_sets) = match crate::config::load_config(&paths.config, &paths.packages) - { - Ok(config_result) => { - let error_sets = config_result - .non_fatal_errors - .into_iter() - .map(|error_set| espanso_modulo::troubleshooting::ErrorSet { - file: Some(error_set.file), - errors: error_set - .errors - .into_iter() - .map(|error| espanso_modulo::troubleshooting::ErrorRecord { - level: match error.level { - espanso_config::error::ErrorLevel::Error => { - espanso_modulo::troubleshooting::ErrorLevel::Error - } - espanso_config::error::ErrorLevel::Warning => { - espanso_modulo::troubleshooting::ErrorLevel::Warning - } - }, - message: format!("{:?}", error.error), - }) - .collect(), - }) - .collect(); + let (is_fatal_error, error_sets) = + match crate::config::load_config(&paths.config, &paths.packages) { + Ok(config_result) => { + let error_sets = config_result + .non_fatal_errors + .into_iter() + .map(|error_set| espanso_modulo::troubleshooting::ErrorSet { + file: Some(error_set.file), + errors: error_set + .errors + .into_iter() + .map(|error| espanso_modulo::troubleshooting::ErrorRecord { + level: match error.level { + espanso_config::error::ErrorLevel::Error => { + espanso_modulo::troubleshooting::ErrorLevel::Error + } + espanso_config::error::ErrorLevel::Warning => { + espanso_modulo::troubleshooting::ErrorLevel::Warning + } + }, + message: format!("{:?}", error.error), + }) + .collect(), + }) + .collect(); - (false, error_sets) - } - Err(err) => { - let message = format!("{:?}", err); - let file_path = if message.contains("default.yml") { - let default_file_path = paths.config.join("config").join("default.yml"); - Some(default_file_path) - } else { - None - }; + (false, error_sets) + } + Err(err) => { + let message = format!("{:?}", err); + let file_path = if message.contains("default.yml") { + let default_file_path = paths.config.join("config").join("default.yml"); + Some(default_file_path) + } else { + None + }; - ( - true, - vec![espanso_modulo::troubleshooting::ErrorSet { - file: file_path, - errors: vec![espanso_modulo::troubleshooting::ErrorRecord { - level: espanso_modulo::troubleshooting::ErrorLevel::Error, - message: format!("{:?}", err), + ( + true, + vec![espanso_modulo::troubleshooting::ErrorSet { + file: file_path, + errors: vec![espanso_modulo::troubleshooting::ErrorRecord { + level: espanso_modulo::troubleshooting::ErrorLevel::Error, + message: format!("{:?}", err), + }], }], - }], - ) - } - }; + ) + } + }; espanso_modulo::troubleshooting::show(TroubleshootingOptions { window_icon_path: icon_paths .wizard_icon .as_ref() .map(|path| path.to_string_lossy().to_string()), - error_sets, + error_sets, is_fatal_error, handlers: TroubleshootingHandlers { dont_show_again_changed: Some(dont_show_again_handler), open_file: Some(open_file_handler), }, - }).expect("troubleshoot GUI returned error"); + }) + .expect("troubleshoot GUI returned error"); 0 } diff --git a/espanso/src/cli/modulo/welcome.rs b/espanso/src/cli/modulo/welcome.rs index 846193f..1a42922 100644 --- a/espanso/src/cli/modulo/welcome.rs +++ b/espanso/src/cli/modulo/welcome.rs @@ -17,8 +17,8 @@ * along with espanso. If not, see . */ -use clap::{ArgMatches}; use crate::icon::IconPaths; +use clap::ArgMatches; use espanso_modulo::welcome::*; use espanso_path::Paths; @@ -30,7 +30,7 @@ pub fn welcome_main(matches: &ArgMatches, _: &Paths, icon_paths: &IconPaths) -> let is_already_running = matches.is_present("already-running"); - espanso_modulo::welcome::show(WelcomeOptions{ + espanso_modulo::welcome::show(WelcomeOptions { window_icon_path: icon_paths .wizard_icon .as_ref() diff --git a/espanso/src/cli/package/install.rs b/espanso/src/cli/package/install.rs index ca74779..a2f7120 100644 --- a/espanso/src/cli/package/install.rs +++ b/espanso/src/cli/package/install.rs @@ -70,8 +70,12 @@ pub fn install_package(paths: &Paths, matches: &ArgMatches) -> Result<()> { error_eprintln!("Error: the requested package is hosted on an external repository"); error_eprintln!("and its contents may not have been verified by the espanso team."); error_eprintln!(""); - error_eprintln!("For security reasons, espanso blocks packages that are not verified by default."); - error_eprintln!("If you want to install the package anyway, you can proceed with the installation"); + error_eprintln!( + "For security reasons, espanso blocks packages that are not verified by default." + ); + error_eprintln!( + "If you want to install the package anyway, you can proceed with the installation" + ); error_eprintln!("by passing the '--external' flag, but please do it only if you trust the"); error_eprintln!("source or you verified the contents of the package yourself."); error_eprintln!(""); diff --git a/espanso/src/cli/package/list.rs b/espanso/src/cli/package/list.rs index ea0cba0..9c1fe38 100644 --- a/espanso/src/cli/package/list.rs +++ b/espanso/src/cli/package/list.rs @@ -42,10 +42,15 @@ pub fn list_packages(paths: &Paths, _: &ArgMatches) -> Result<()> { match package { StoredPackage::Legacy(legacy) => { info_println!("- {} (legacy)", legacy.name); - }, + } StoredPackage::Modern(package) => { - info_println!("- {} - version: {} ({})", package.manifest.name, package.manifest.version, package.source); - }, + info_println!( + "- {} - version: {} ({})", + package.manifest.name, + package.manifest.version, + package.source + ); + } } } diff --git a/espanso/src/cli/package/uninstall.rs b/espanso/src/cli/package/uninstall.rs index bba7aaf..0751991 100644 --- a/espanso/src/cli/package/uninstall.rs +++ b/espanso/src/cli/package/uninstall.rs @@ -31,7 +31,9 @@ pub fn uninstall_package(paths: &Paths, matches: &ArgMatches) -> Result<()> { let archiver = espanso_package::get_archiver(&paths.packages).context("unable to get package archiver")?; - archiver.delete(package_name).context("unable to delete package")?; + archiver + .delete(package_name) + .context("unable to delete package")?; info_println!("package '{}' uninstalled!", package_name); diff --git a/espanso/src/cli/path.rs b/espanso/src/cli/path.rs index e80717e..d4c3140 100644 --- a/espanso/src/cli/path.rs +++ b/espanso/src/cli/path.rs @@ -37,25 +37,41 @@ fn path_main(args: CliModuleArgs) -> i32 { println!("{}", paths.config.to_string_lossy()); } else if cli_args.subcommand_matches("packages").is_some() { println!("{}", paths.packages.to_string_lossy()); - } else if cli_args.subcommand_matches("data").is_some() || cli_args.subcommand_matches("runtime").is_some() { + } else if cli_args.subcommand_matches("data").is_some() + || cli_args.subcommand_matches("runtime").is_some() + { println!("{}", paths.runtime.to_string_lossy()); } else if cli_args.subcommand_matches("default").is_some() { if args.is_legacy_config { println!("{}", paths.config.join("default.yml").to_string_lossy()); } else { - println!("{}", paths.config.join("config").join("default.yml").to_string_lossy()); + println!( + "{}", + paths + .config + .join("config") + .join("default.yml") + .to_string_lossy() + ); } } else if cli_args.subcommand_matches("base").is_some() { if args.is_legacy_config { eprintln!("base config not available when using legacy configuration format"); } else { - println!("{}", paths.config.join("match").join("base.yml").to_string_lossy()); + println!( + "{}", + paths + .config + .join("match") + .join("base.yml") + .to_string_lossy() + ); } } else { println!("Config: {}", paths.config.to_string_lossy()); println!("Packages: {}", paths.packages.to_string_lossy()); println!("Runtime: {}", paths.runtime.to_string_lossy()); } - + 0 } diff --git a/espanso/src/cli/service/linux.rs b/espanso/src/cli/service/linux.rs index 1c7723c..792993c 100644 --- a/espanso/src/cli/service/linux.rs +++ b/espanso/src/cli/service/linux.rs @@ -20,9 +20,9 @@ use anyhow::Result; use const_format::formatcp; use regex::Regex; +use std::fs::create_dir_all; use std::path::PathBuf; use std::process::{Command, Stdio}; -use std::{fs::create_dir_all}; use thiserror::Error; use crate::{error_eprintln, info_println, warn_eprintln}; @@ -143,8 +143,7 @@ pub fn is_registered() -> bool { if cmd_output.status.success() { let caps = EXEC_PATH_REGEX.captures(output).unwrap(); let path = caps.get(1).map_or("", |m| m.as_str()); - let espanso_path = - get_binary_path().expect("unable to get espanso executable path"); + let espanso_path = get_binary_path().expect("unable to get espanso executable path"); if espanso_path.to_string_lossy() != path { error_eprintln!("Espanso is registered as a systemd service, but it points to another binary location:"); @@ -195,8 +194,12 @@ pub fn start_service() -> Result<()> { ); error_eprintln!("You can run it in unmanaged mode with `espanso service start --unmanaged`"); error_eprintln!(""); - error_eprintln!("NOTE: unmanaged mode means espanso does not rely on the system service manager"); - error_eprintln!(" to run, but as a result, you are in charge of starting/stopping espanso"); + error_eprintln!( + "NOTE: unmanaged mode means espanso does not rely on the system service manager" + ); + error_eprintln!( + " to run, but as a result, you are in charge of starting/stopping espanso" + ); error_eprintln!(" when needed."); return Err(StartError::SystemdNotFound.into()); } @@ -207,8 +210,12 @@ pub fn start_service() -> Result<()> { error_eprintln!("You can either register it first with `espanso service register` or"); error_eprintln!("you can run it in unmanaged mode with `espanso service start --unmanaged`"); error_eprintln!(""); - error_eprintln!("NOTE: unmanaged mode means espanso does not rely on the system service manager"); - error_eprintln!(" to run, but as a result, you are in charge of starting/stopping espanso"); + error_eprintln!( + "NOTE: unmanaged mode means espanso does not rely on the system service manager" + ); + error_eprintln!( + " to run, but as a result, you are in charge of starting/stopping espanso" + ); error_eprintln!(" when needed."); return Err(StartError::NotRegistered.into()); } @@ -274,4 +281,4 @@ fn get_binary_path() -> Result { } Ok(std::env::current_exe()?) -} \ No newline at end of file +} diff --git a/espanso/src/cli/service/mod.rs b/espanso/src/cli/service/mod.rs index 6e0ff67..eb250df 100644 --- a/espanso/src/cli/service/mod.rs +++ b/espanso/src/cli/service/mod.rs @@ -18,7 +18,15 @@ */ use super::{CliModule, CliModuleArgs}; -use crate::{error_eprintln, exit_code::{SERVICE_ALREADY_RUNNING, SERVICE_FAILURE, SERVICE_NOT_REGISTERED, SERVICE_NOT_RUNNING, SERVICE_SUCCESS}, info_println, lock::acquire_worker_lock}; +use crate::{ + error_eprintln, + exit_code::{ + SERVICE_ALREADY_RUNNING, SERVICE_FAILURE, SERVICE_NOT_REGISTERED, SERVICE_NOT_RUNNING, + SERVICE_SUCCESS, + }, + info_println, + lock::acquire_worker_lock, +}; #[cfg(target_os = "macos")] mod macos; @@ -123,7 +131,7 @@ fn service_main(args: CliModuleArgs) -> i32 { error_eprintln!("unable to stop espanso: {}", err); return SERVICE_FAILURE; } - } + } SERVICE_SUCCESS } diff --git a/espanso/src/cli/service/unix.rs b/espanso/src/cli/service/unix.rs index 6c3ffb5..c7d7d4b 100644 --- a/espanso/src/cli/service/unix.rs +++ b/espanso/src/cli/service/unix.rs @@ -17,9 +17,9 @@ * along with espanso. If not, see . */ +use crate::cli::util::CommandExt; use anyhow::Result; use thiserror::Error; -use crate::cli::util::CommandExt; use crate::cli::PathsOverrides; diff --git a/espanso/src/cli/service/win.rs b/espanso/src/cli/service/win.rs index d2f7faa..3fa25dd 100644 --- a/espanso/src/cli/service/win.rs +++ b/espanso/src/cli/service/win.rs @@ -18,11 +18,11 @@ */ use anyhow::Result; +use std::fs::create_dir_all; +use std::os::windows::process::CommandExt; use std::path::{Path, PathBuf}; use std::process::Command; -use std::{fs::create_dir_all}; use thiserror::Error; -use std::os::windows::process::CommandExt; use crate::{error_eprintln, warn_eprintln}; @@ -30,7 +30,7 @@ pub fn register() -> Result<()> { let current_path = std::env::current_exe().expect("unable to get exec path"); let shortcut_path = get_startup_shortcut_file()?; - + create_shortcut_target_file(&shortcut_path, ¤t_path, "launcher") } @@ -40,7 +40,7 @@ pub fn unregister() -> Result<()> { error_eprintln!("could not unregister espanso, as it's not registered"); return Err(UnregisterError::EntryNotFound.into()); } - + std::fs::remove_file(shortcut_path)?; Ok(()) @@ -67,19 +67,21 @@ pub fn is_registered() -> bool { if current_path != target_path { warn_eprintln!("WARNING: Espanso is already registered as a service, but it points to another executable,"); warn_eprintln!("which can create some inconsistencies."); - warn_eprintln!("To fix the problem, unregister and register espanso again with these commands:"); + warn_eprintln!( + "To fix the problem, unregister and register espanso again with these commands:" + ); warn_eprintln!(""); warn_eprintln!(" espanso service unregister"); warn_eprintln!(" espanso service register"); warn_eprintln!(""); } - + true - }, + } Err(err) => { error_eprintln!("unable to determine shortcut target path: {}", err); false - }, + } } } Err(err) => { @@ -138,7 +140,11 @@ fn get_shortcut_target_file(shortcut_path: &Path) -> Result { Ok(path) } -fn create_shortcut_target_file(shortcut_path: &Path, target_path: &Path, arguments: &str) -> Result<()> { +fn create_shortcut_target_file( + shortcut_path: &Path, + target_path: &Path, + arguments: &str, +) -> Result<()> { let output = Command::new("powershell") .arg("-c") .arg("$WshShell = New-Object -comObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut($env:SHORTCUT_PATH); $Shortcut.TargetPath = $env:TARGET_PATH; $Shortcut.Arguments = $env:TARGET_ARGS; $Shortcut.Save()") diff --git a/espanso/src/cli/workaround/mod.rs b/espanso/src/cli/workaround/mod.rs index 2deae5d..857c61f 100644 --- a/espanso/src/cli/workaround/mod.rs +++ b/espanso/src/cli/workaround/mod.rs @@ -18,7 +18,7 @@ */ use super::{CliModule, CliModuleArgs}; -use crate::{error_eprintln, exit_code::{WORKAROUND_SUCCESS}}; +use crate::{error_eprintln, exit_code::WORKAROUND_SUCCESS}; #[cfg(target_os = "macos")] mod secure_input; diff --git a/espanso/src/cli/workaround/secure_input.rs b/espanso/src/cli/workaround/secure_input.rs index a14bb4c..dd00429 100644 --- a/espanso/src/cli/workaround/secure_input.rs +++ b/espanso/src/cli/workaround/secure_input.rs @@ -27,11 +27,9 @@ use std::{ const BLUR_CHROME_WINDOWS_SCRIPT: &str = include_str!("../../res/macos/scripts/blur_chrome_windows.scpt"); -const GET_RUNNING_APPS_SCRIPT: &str = - include_str!("../../res/macos/scripts/get_running_apps.scpt"); +const GET_RUNNING_APPS_SCRIPT: &str = include_str!("../../res/macos/scripts/get_running_apps.scpt"); -const FOCUS_BITWARDEN_SCRIPT: &str = - include_str!("../../res/macos/scripts/focus_bitwarden.scpt"); +const FOCUS_BITWARDEN_SCRIPT: &str = include_str!("../../res/macos/scripts/focus_bitwarden.scpt"); const SECURE_INPUT_ASK_LOCK_SCREEN_SCRIPT: &str = include_str!("../../res/macos/scripts/secure_input_ask_lock_screen.scpt"); diff --git a/espanso/src/cli/worker/builtin/process.rs b/espanso/src/cli/worker/builtin/process.rs index d17c7f5..b09b752 100644 --- a/espanso/src/cli/worker/builtin/process.rs +++ b/espanso/src/cli/worker/builtin/process.rs @@ -28,9 +28,7 @@ pub fn create_match_exit() -> BuiltInMatch { id: generate_next_builtin_id(), label: "Exit espanso", triggers: Vec::new(), - action: |_| { - EventType::ExitRequested(ExitMode::ExitAllProcesses) - }, + action: |_| EventType::ExitRequested(ExitMode::ExitAllProcesses), ..Default::default() } } @@ -40,9 +38,7 @@ pub fn create_match_restart() -> BuiltInMatch { id: generate_next_builtin_id(), label: "Restart espanso", triggers: Vec::new(), - action: |_| { - EventType::ExitRequested(ExitMode::RestartWorker) - }, + action: |_| EventType::ExitRequested(ExitMode::RestartWorker), ..Default::default() } -} \ No newline at end of file +} diff --git a/espanso/src/cli/worker/config.rs b/espanso/src/cli/worker/config.rs index cc78531..c4808bb 100644 --- a/espanso/src/cli/worker/config.rs +++ b/espanso/src/cli/worker/config.rs @@ -86,7 +86,8 @@ impl<'a> espanso_engine::process::MatchFilter for ConfigManager<'a> { let builtin_matches: Vec = matches_ids .iter() - .filter(|id| is_builtin_match(**id)).copied() + .filter(|id| is_builtin_match(**id)) + .copied() .collect(); let mut output = active_user_defined_matches; @@ -164,9 +165,9 @@ impl<'a> espanso_engine::process::UndoEnabledProvider for ConfigManager<'a> { fn is_undo_enabled(&self) -> bool { // Disable undo_backspace on Wayland for now as it's not stable if cfg!(feature = "wayland") { - return false + return false; } - + self.active().undo_backspace() } } diff --git a/espanso/src/cli/worker/context/mod.rs b/espanso/src/cli/worker/context/mod.rs index ffa034b..d3af481 100644 --- a/espanso/src/cli/worker/context/mod.rs +++ b/espanso/src/cli/worker/context/mod.rs @@ -23,7 +23,7 @@ use espanso_config::config::Config; mod default; pub use default::DefaultContext; -use espanso_info::{AppInfo}; +use espanso_info::AppInfo; pub trait Context: ConfigContext + AppInfoContext {} @@ -34,4 +34,4 @@ pub trait ConfigContext { pub trait AppInfoContext { fn get_active_app_info(&self) -> AppInfo; -} \ No newline at end of file +} diff --git a/espanso/src/cli/worker/engine/caches/app_info_provider.rs b/espanso/src/cli/worker/engine/caches/app_info_provider.rs index 6b03863..a0184ff 100644 --- a/espanso/src/cli/worker/engine/caches/app_info_provider.rs +++ b/espanso/src/cli/worker/engine/caches/app_info_provider.rs @@ -17,14 +17,17 @@ * along with espanso. If not, see . */ -use std::{cell::RefCell, time::{Duration, Instant}}; +use std::{ + cell::RefCell, + time::{Duration, Instant}, +}; use espanso_info::{AppInfo, AppInfoProvider}; pub struct CachedAppInfoProvider<'a> { app_info_provider: &'a dyn AppInfoProvider, caching_interval: Duration, - + _cached_info: RefCell>, } @@ -50,7 +53,7 @@ impl<'a> AppInfoProvider for CachedAppInfoProvider<'a> { let info = self.app_info_provider.get_info(); *cached_info = Some((Instant::now(), info.clone())); - + info } } diff --git a/espanso/src/cli/worker/engine/caches/mod.rs b/espanso/src/cli/worker/engine/caches/mod.rs index d5f2e9d..46e020a 100644 --- a/espanso/src/cli/worker/engine/caches/mod.rs +++ b/espanso/src/cli/worker/engine/caches/mod.rs @@ -17,4 +17,4 @@ * along with espanso. If not, see . */ -pub mod app_info_provider; \ No newline at end of file +pub mod app_info_provider; diff --git a/espanso/src/cli/worker/engine/dispatch/executor/clipboard_injector.rs b/espanso/src/cli/worker/engine/dispatch/executor/clipboard_injector.rs index 5207f4a..8ebfd54 100644 --- a/espanso/src/cli/worker/engine/dispatch/executor/clipboard_injector.rs +++ b/espanso/src/cli/worker/engine/dispatch/executor/clipboard_injector.rs @@ -89,7 +89,7 @@ impl<'a> ClipboardInjectorAdapter<'a> { InjectionOptions { delay: params.paste_shortcut_event_delay as i32, disable_fast_inject: params.disable_x11_fast_inject, - ..Default::default() + ..Default::default() }, )?; diff --git a/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs b/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs index ba71ce8..01b8711 100644 --- a/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs +++ b/espanso/src/cli/worker/engine/dispatch/executor/context_menu.rs @@ -40,7 +40,7 @@ impl<'a> ContextMenuHandler for ContextMenuHandlerAdapter<'a> { }; self.remote.show_context_menu(&ui_menu); - + Ok(()) } } diff --git a/espanso/src/cli/worker/engine/dispatch/executor/icon.rs b/espanso/src/cli/worker/engine/dispatch/executor/icon.rs index a0c6450..0956cd2 100644 --- a/espanso/src/cli/worker/engine/dispatch/executor/icon.rs +++ b/espanso/src/cli/worker/engine/dispatch/executor/icon.rs @@ -17,7 +17,7 @@ * along with espanso. If not, see . */ -use espanso_ui::{UIRemote, icons::TrayIcon}; +use espanso_ui::{icons::TrayIcon, UIRemote}; use espanso_engine::{dispatch::IconHandler, event::ui::IconStatus}; @@ -35,12 +35,12 @@ impl<'a> IconHandler for IconHandlerAdapter<'a> { fn update_icon(&self, status: &IconStatus) -> anyhow::Result<()> { let icon = match status { IconStatus::Enabled => TrayIcon::Normal, - IconStatus::Disabled => TrayIcon::Disabled, - IconStatus::SecureInputDisabled => TrayIcon::SystemDisabled, + IconStatus::Disabled => TrayIcon::Disabled, + IconStatus::SecureInputDisabled => TrayIcon::SystemDisabled, }; self.remote.update_tray_icon(icon); Ok(()) } -} \ No newline at end of file +} diff --git a/espanso/src/cli/worker/engine/dispatch/executor/mod.rs b/espanso/src/cli/worker/engine/dispatch/executor/mod.rs index 7f3ff9d..7fee77a 100644 --- a/espanso/src/cli/worker/engine/dispatch/executor/mod.rs +++ b/espanso/src/cli/worker/engine/dispatch/executor/mod.rs @@ -33,4 +33,4 @@ pub struct InjectParams { pub key_delay: Option, pub disable_x11_fast_inject: bool, pub evdev_modifier_delay: Option, -} \ No newline at end of file +} diff --git a/espanso/src/cli/worker/engine/dispatch/mod.rs b/espanso/src/cli/worker/engine/dispatch/mod.rs index 97d52a6..a38d5ca 100644 --- a/espanso/src/cli/worker/engine/dispatch/mod.rs +++ b/espanso/src/cli/worker/engine/dispatch/mod.rs @@ -17,4 +17,4 @@ * along with espanso. If not, see . */ -pub mod executor; \ No newline at end of file +pub mod executor; diff --git a/espanso/src/cli/worker/engine/funnel/detect.rs b/espanso/src/cli/worker/engine/funnel/detect.rs index ddd2e50..f0a074f 100644 --- a/espanso/src/cli/worker/engine/funnel/detect.rs +++ b/espanso/src/cli/worker/engine/funnel/detect.rs @@ -48,9 +48,7 @@ impl<'a> funnel::Source<'a> for DetectSource { key: convert_to_engine_key(keyboard_event.key), value: keyboard_event.value, status: convert_to_engine_status(keyboard_event.status), - variant: keyboard_event - .variant - .map(convert_to_engine_variant), + variant: keyboard_event.variant.map(convert_to_engine_variant), }), }, InputEvent::Mouse(mouse_event) => Event { diff --git a/espanso/src/cli/worker/engine/funnel/exit.rs b/espanso/src/cli/worker/engine/funnel/exit.rs index 3efb006..ad1f540 100644 --- a/espanso/src/cli/worker/engine/funnel/exit.rs +++ b/espanso/src/cli/worker/engine/funnel/exit.rs @@ -19,7 +19,10 @@ use crossbeam::channel::{Receiver, Select, SelectedOperation}; -use espanso_engine::{event::{Event, EventType, ExitMode}, funnel}; +use espanso_engine::{ + event::{Event, EventType, ExitMode}, + funnel, +}; use super::sequencer::Sequencer; @@ -28,7 +31,7 @@ pub struct ExitSource<'a> { pub sequencer: &'a Sequencer, } -impl <'a> ExitSource<'a> { +impl<'a> ExitSource<'a> { pub fn new(exit_signal: Receiver, sequencer: &'a Sequencer) -> Self { ExitSource { exit_signal, @@ -51,4 +54,4 @@ impl<'a> funnel::Source<'a> for ExitSource<'a> { etype: EventType::ExitRequested(mode), } } -} \ No newline at end of file +} diff --git a/espanso/src/cli/worker/engine/mod.rs b/espanso/src/cli/worker/engine/mod.rs index 2541456..53e21b5 100644 --- a/espanso/src/cli/worker/engine/mod.rs +++ b/espanso/src/cli/worker/engine/mod.rs @@ -29,7 +29,16 @@ use espanso_path::Paths; use espanso_ui::{event::UIEvent, UIRemote}; use log::{debug, error, info, warn}; -use crate::{cli::worker::{context::Context, engine::{dispatch::executor::{clipboard_injector::ClipboardInjectorAdapter, context_menu::ContextMenuHandlerAdapter, event_injector::EventInjectorAdapter, icon::IconHandlerAdapter, key_injector::KeyInjectorAdapter, secure_input::SecureInputManagerAdapter}, process::middleware::{ +use crate::{ + cli::worker::{ + context::Context, + engine::{ + dispatch::executor::{ + clipboard_injector::ClipboardInjectorAdapter, context_menu::ContextMenuHandlerAdapter, + event_injector::EventInjectorAdapter, icon::IconHandlerAdapter, + key_injector::KeyInjectorAdapter, secure_input::SecureInputManagerAdapter, + }, + process::middleware::{ image_resolve::PathProviderAdapter, match_select::MatchSelectorAdapter, matcher::{ @@ -42,15 +51,25 @@ use crate::{cli::worker::{context::Context, engine::{dispatch::executor::{clipbo extension::{clipboard::ClipboardAdapter, form::FormProviderAdapter}, RendererAdapter, }, - }}, match_cache::{CombinedMatchCache, MatchCache}, ui::notification::NotificationManager}, common_flags::{WORKER_START_REASON_CONFIG_CHANGED, WORKER_START_REASON_KEYBOARD_LAYOUT_CHANGED, WORKER_START_REASON_MANUAL}, preferences::Preferences}; + }, + }, + match_cache::{CombinedMatchCache, MatchCache}, + ui::notification::NotificationManager, + }, + common_flags::{ + WORKER_START_REASON_CONFIG_CHANGED, WORKER_START_REASON_KEYBOARD_LAYOUT_CHANGED, + WORKER_START_REASON_MANUAL, + }, + preferences::Preferences, +}; use super::secure_input::SecureInputEvent; +mod caches; pub mod dispatch; pub mod funnel; -pub mod process; -mod caches; mod keyboard_layout_util; +pub mod process; #[allow(clippy::too_many_arguments)] pub fn initialize_and_spawn( @@ -68,12 +87,16 @@ 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 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"); // TODO: read interval from configs? - let cached_app_info_provider = caches::app_info_provider::CachedAppInfoProvider::from(&*app_info_provider, std::time::Duration::from_millis(400)); + let cached_app_info_provider = caches::app_info_provider::CachedAppInfoProvider::from( + &*app_info_provider, + std::time::Duration::from_millis(400), + ); let config_manager = super::config::ConfigManager::new(&*config_store, &*match_store, &cached_app_info_provider); let match_cache = MatchCache::load(&*config_store, &*match_store); @@ -83,7 +106,10 @@ pub fn initialize_and_spawn( let modulo_form_ui = crate::gui::modulo::form::ModuloFormUI::new(&modulo_manager); let modulo_search_ui = crate::gui::modulo::search::ModuloSearchUI::new(&modulo_manager); - let context: Box = Box::new(super::context::DefaultContext::new(&config_manager, &cached_app_info_provider)); + let context: Box = Box::new(super::context::DefaultContext::new( + &config_manager, + &cached_app_info_provider, + )); let builtin_matches = super::builtin::get_builtin_matches(&*config_manager.default()); let combined_match_cache = CombinedMatchCache::load(&match_cache, &builtin_matches); @@ -95,7 +121,9 @@ pub fn initialize_and_spawn( let (detect_source, modifier_state_store, sequencer, key_state_store) = super::engine::funnel::init_and_spawn(SourceCreationOptions { use_evdev: use_evdev_backend, - evdev_keyboard_rmlvo: keyboard_layout_util::generate_detect_rmlvo(&*config_manager.default()), + evdev_keyboard_rmlvo: keyboard_layout_util::generate_detect_rmlvo( + &*config_manager.default(), + ), hotkeys: match_converter.get_hotkeys(), win32_exclude_orphan_events: default_config.win32_exclude_orphan_events(), }) @@ -136,8 +164,11 @@ pub fn initialize_and_spawn( let injector = espanso_inject::get_injector(InjectorCreationOptions { use_evdev: use_evdev_backend, - keyboard_state_provider: key_state_store.map(|store| Box::new(store) as Box), - evdev_keyboard_rmlvo: keyboard_layout_util::generate_inject_rmlvo(&*config_manager.default()), + keyboard_state_provider: key_state_store + .map(|store| Box::new(store) as Box), + evdev_keyboard_rmlvo: keyboard_layout_util::generate_inject_rmlvo( + &*config_manager.default(), + ), ..Default::default() }) .expect("failed to initialize injector module"); // TODO: handle the options @@ -234,7 +265,7 @@ pub fn initialize_and_spawn( } _ => { notification_manager.notify_start(); - + if !preferences.has_displayed_welcome() { super::ui::welcome::show_welcome_screen(); preferences.set_has_displayed_welcome(true); diff --git a/espanso/src/cli/worker/engine/process/middleware/match_select.rs b/espanso/src/cli/worker/engine/process/middleware/match_select.rs index c6e816a..b318bc2 100644 --- a/espanso/src/cli/worker/engine/process/middleware/match_select.rs +++ b/espanso/src/cli/worker/engine/process/middleware/match_select.rs @@ -65,7 +65,7 @@ impl<'a> MatchSelector for MatchSelectorAdapter<'a> { } }) .collect(); - + let hint = if is_search { Some("Search matches by content or trigger (or type > to see commands)") } else { diff --git a/espanso/src/cli/worker/engine/process/middleware/matcher/convert.rs b/espanso/src/cli/worker/engine/process/middleware/matcher/convert.rs index ff34c55..71cfa70 100644 --- a/espanso/src/cli/worker/engine/process/middleware/matcher/convert.rs +++ b/espanso/src/cli/worker/engine/process/middleware/matcher/convert.rs @@ -124,6 +124,8 @@ impl<'a> MatchConverter<'a> { fn global_match_set(&self) -> MatchSet { let paths = self.config_store.get_all_match_paths(); - self.match_store.query(&paths.into_iter().collect::>()) + self + .match_store + .query(&paths.into_iter().collect::>()) } } diff --git a/espanso/src/cli/worker/engine/process/middleware/mod.rs b/espanso/src/cli/worker/engine/process/middleware/mod.rs index d525b85..d3998bf 100644 --- a/espanso/src/cli/worker/engine/process/middleware/mod.rs +++ b/espanso/src/cli/worker/engine/process/middleware/mod.rs @@ -19,7 +19,7 @@ pub mod disable; pub mod image_resolve; -pub mod matcher; pub mod match_select; +pub mod matcher; pub mod multiplex; -pub mod render; \ No newline at end of file +pub mod render; diff --git a/espanso/src/cli/worker/engine/process/middleware/render/extension/clipboard.rs b/espanso/src/cli/worker/engine/process/middleware/render/extension/clipboard.rs index dfbe441..57b2c91 100644 --- a/espanso/src/cli/worker/engine/process/middleware/render/extension/clipboard.rs +++ b/espanso/src/cli/worker/engine/process/middleware/render/extension/clipboard.rs @@ -24,11 +24,9 @@ pub struct ClipboardAdapter<'a> { clipboard: &'a dyn Clipboard, } -impl <'a> ClipboardAdapter<'a> { +impl<'a> ClipboardAdapter<'a> { pub fn new(clipboard: &'a dyn Clipboard) -> Self { - Self { - clipboard - } + Self { clipboard } } } diff --git a/espanso/src/cli/worker/engine/process/middleware/render/extension/mod.rs b/espanso/src/cli/worker/engine/process/middleware/render/extension/mod.rs index 6291f83..d7cafac 100644 --- a/espanso/src/cli/worker/engine/process/middleware/render/extension/mod.rs +++ b/espanso/src/cli/worker/engine/process/middleware/render/extension/mod.rs @@ -18,4 +18,4 @@ */ pub mod clipboard; -pub mod form; \ No newline at end of file +pub mod form; diff --git a/espanso/src/cli/worker/engine/process/middleware/render/mod.rs b/espanso/src/cli/worker/engine/process/middleware/render/mod.rs index 98b1afa..e2f73ea 100644 --- a/espanso/src/cli/worker/engine/process/middleware/render/mod.rs +++ b/espanso/src/cli/worker/engine/process/middleware/render/mod.rs @@ -86,7 +86,9 @@ fn generate_global_vars_map(config_provider: &dyn ConfigProvider) -> HashMap. */ -pub mod middleware; \ No newline at end of file +pub mod middleware; diff --git a/espanso/src/cli/worker/match_cache.rs b/espanso/src/cli/worker/match_cache.rs index 2d85f72..fe23b7d 100644 --- a/espanso/src/cli/worker/match_cache.rs +++ b/espanso/src/cli/worker/match_cache.rs @@ -17,7 +17,7 @@ * along with espanso. If not, see . */ -use std::{collections::HashMap}; +use std::collections::HashMap; use espanso_config::{ config::ConfigStore, diff --git a/espanso/src/cli/worker/ui/mod.rs b/espanso/src/cli/worker/ui/mod.rs index 68e2482..bcb5b10 100644 --- a/espanso/src/cli/worker/ui/mod.rs +++ b/espanso/src/cli/worker/ui/mod.rs @@ -19,4 +19,4 @@ pub mod notification; pub mod util; -pub mod welcome; \ No newline at end of file +pub mod welcome; diff --git a/espanso/src/cli/worker/ui/util.rs b/espanso/src/cli/worker/ui/util.rs index 1bd4638..f9b8e7e 100644 --- a/espanso/src/cli/worker/ui/util.rs +++ b/espanso/src/cli/worker/ui/util.rs @@ -34,8 +34,11 @@ pub fn convert_icon_paths_to_tray_vec(icon_paths: &IconPaths) -> Vec<(TrayIcon, } if let Some(system_disabled) = &icon_paths.tray_icon_system_disabled { - paths.push((TrayIcon::SystemDisabled, system_disabled.to_string_lossy().to_string())); + paths.push(( + TrayIcon::SystemDisabled, + system_disabled.to_string_lossy().to_string(), + )); } paths -} \ No newline at end of file +} diff --git a/espanso/src/common_flags.rs b/espanso/src/common_flags.rs index 3255d6b..bf54654 100644 --- a/espanso/src/common_flags.rs +++ b/espanso/src/common_flags.rs @@ -19,4 +19,4 @@ pub const WORKER_START_REASON_MANUAL: &str = "manual_restart"; pub const WORKER_START_REASON_CONFIG_CHANGED: &str = "config_changed"; -pub const WORKER_START_REASON_KEYBOARD_LAYOUT_CHANGED: &str = "keyboard_layout_changed"; \ No newline at end of file +pub const WORKER_START_REASON_KEYBOARD_LAYOUT_CHANGED: &str = "keyboard_layout_changed"; diff --git a/espanso/src/gui/mod.rs b/espanso/src/gui/mod.rs index 3920c35..bcd26e7 100644 --- a/espanso/src/gui/mod.rs +++ b/espanso/src/gui/mod.rs @@ -36,7 +36,11 @@ pub struct SearchItem { } pub trait FormUI { - fn show(&self, layout: &str, fields: &HashMap) -> Result>>; + fn show( + &self, + layout: &str, + fields: &HashMap, + ) -> Result>>; } #[derive(Debug)] @@ -52,5 +56,5 @@ pub enum FormField { List { default: Option, values: Vec, - } -} \ No newline at end of file + }, +} diff --git a/espanso/src/gui/modulo/form.rs b/espanso/src/gui/modulo/form.rs index 27ddccc..6c0f778 100644 --- a/espanso/src/gui/modulo/form.rs +++ b/espanso/src/gui/modulo/form.rs @@ -19,7 +19,7 @@ use serde::Serialize; use serde_json::{json, Map, Value}; -use std::{collections::HashMap}; +use std::collections::HashMap; use crate::gui::{FormField, FormUI}; @@ -31,9 +31,7 @@ pub struct ModuloFormUI<'a> { impl<'a> ModuloFormUI<'a> { pub fn new(manager: &'a ModuloManager) -> Self { - Self { - manager, - } + Self { manager } } } @@ -62,9 +60,7 @@ impl<'a> FormUI for ModuloFormUI<'a> { Ok(Some(json)) } } - Err(error) => { - Err(error.into()) - } + Err(error) => Err(error.into()), } } } diff --git a/espanso/src/gui/modulo/manager.rs b/espanso/src/gui/modulo/manager.rs index 9f4bbde..0cc3184 100644 --- a/espanso/src/gui/modulo/manager.rs +++ b/espanso/src/gui/modulo/manager.rs @@ -77,22 +77,16 @@ impl ModuloManager { Err(ModuloError::EmptyOutput.into()) } } - Err(error) => { - Err(ModuloError::Error(error).into()) - } + Err(error) => Err(ModuloError::Error(error).into()), } } - Err(error) => { - Err(ModuloError::Error(error).into()) - } + Err(error) => Err(ModuloError::Error(error).into()), } } else { Err(ModuloError::StdinError.into()) } } - Err(error) => { - Err(ModuloError::Error(error).into()) - } + Err(error) => Err(ModuloError::Error(error).into()), } } else { Err(ModuloError::MissingModulo.into()) @@ -102,7 +96,9 @@ impl ModuloManager { #[derive(Error, Debug)] pub enum ModuloError { - #[error("attempt to invoke modulo, but this version of espanso is not compiled with support for it")] + #[error( + "attempt to invoke modulo, but this version of espanso is not compiled with support for it" + )] MissingModulo, #[error("modulo returned an empty output")] diff --git a/espanso/src/gui/modulo/mod.rs b/espanso/src/gui/modulo/mod.rs index 296e739..9e27396 100644 --- a/espanso/src/gui/modulo/mod.rs +++ b/espanso/src/gui/modulo/mod.rs @@ -19,4 +19,4 @@ pub mod form; pub mod manager; -pub mod search; \ No newline at end of file +pub mod search; diff --git a/espanso/src/gui/modulo/search.rs b/espanso/src/gui/modulo/search.rs index 02a5405..163ef94 100644 --- a/espanso/src/gui/modulo/search.rs +++ b/espanso/src/gui/modulo/search.rs @@ -19,7 +19,7 @@ use serde::Serialize; use serde_json::Value; -use std::{collections::HashMap}; +use std::collections::HashMap; use crate::gui::{SearchItem, SearchUI}; @@ -31,9 +31,7 @@ pub struct ModuloSearchUI<'a> { impl<'a> ModuloSearchUI<'a> { pub fn new(manager: &'a ModuloManager) -> Self { - Self { - manager, - } + Self { manager } } } @@ -58,9 +56,7 @@ impl<'a> SearchUI for ModuloSearchUI<'a> { Ok(None) } } - Err(error) => { - Err(error.into()) - } + Err(error) => Err(error.into()), } } } @@ -82,10 +78,13 @@ struct ModuloSearchItemConfig<'a> { // TODO: test fn convert_items(items: &[SearchItem]) -> Vec { - items.iter().map(|item| ModuloSearchItemConfig { - id: &item.id, - label: &item.label, - trigger: item.tag.as_deref(), - is_builtin: item.is_builtin, - }).collect() + items + .iter() + .map(|item| ModuloSearchItemConfig { + id: &item.id, + label: &item.label, + trigger: item.tag.as_deref(), + is_builtin: item.is_builtin, + }) + .collect() } diff --git a/espanso/src/icon.rs b/espanso/src/icon.rs index dd8d63f..b0d6e03 100644 --- a/espanso/src/icon.rs +++ b/espanso/src/icon.rs @@ -33,7 +33,6 @@ const WINDOWS_LOGO_ICO_BINARY: &[u8] = include_bytes!("res/windows/logo.ico"); #[cfg(target_os = "windows")] const WINDOWS_TRAY_EXPLAIN_IMAGE: &[u8] = include_bytes!("res/windows/tray_explain_image.png"); - #[cfg(target_os = "macos")] const MAC_BINARY: &[u8] = include_bytes!("res/macos/icon.png"); #[cfg(target_os = "macos")] @@ -61,21 +60,39 @@ pub struct IconPaths { pub accessibility_image_2: Option, pub tray_explain_image: Option, - pub logo: Option, + pub logo: Option, pub logo_no_background: Option, } #[cfg(target_os = "windows")] 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"))?), + 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"))?), + 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"))?), - logo_no_background: Some(extract_icon(LOGO_NO_BACKGROUND_BINARY, &runtime_dir.join("icon_no_background.png"))?), - tray_explain_image: Some(extract_icon(WINDOWS_TRAY_EXPLAIN_IMAGE, &runtime_dir.join("tray_explain_image.png"))?), + logo_no_background: Some(extract_icon( + LOGO_NO_BACKGROUND_BINARY, + &runtime_dir.join("icon_no_background.png"), + )?), + tray_explain_image: Some(extract_icon( + WINDOWS_TRAY_EXPLAIN_IMAGE, + &runtime_dir.join("tray_explain_image.png"), + )?), ..Default::default() }) } @@ -85,13 +102,31 @@ pub fn load_icon_paths(runtime_dir: &Path) -> Result { Ok(IconPaths { search_icon: Some(extract_icon(ICON_BINARY, &runtime_dir.join("search.png"))?), tray_icon_normal: Some(extract_icon(MAC_BINARY, &runtime_dir.join("normal.png"))?), - tray_icon_disabled: Some(extract_icon(MAC_DISABLED_BINARY, &runtime_dir.join("disabled.png"))?), - tray_icon_system_disabled: Some(extract_icon(MAC_SYSTEM_DISABLED_BINARY, &runtime_dir.join("systemdisabled.png"))?), + tray_icon_disabled: Some(extract_icon( + MAC_DISABLED_BINARY, + &runtime_dir.join("disabled.png"), + )?), + tray_icon_system_disabled: Some(extract_icon( + MAC_SYSTEM_DISABLED_BINARY, + &runtime_dir.join("systemdisabled.png"), + )?), logo: Some(extract_icon(ICON_BINARY, &runtime_dir.join("icon.png"))?), - logo_no_background: Some(extract_icon(LOGO_NO_BACKGROUND_BINARY, &runtime_dir.join("icon_no_background.png"))?), - accessibility_image_1: Some(extract_icon(MAC_ACCESSIBILITY_1_BINARY, &runtime_dir.join("accessibility_1.png"))?), - accessibility_image_2: Some(extract_icon(MAC_ACCESSIBILITY_2_BINARY, &runtime_dir.join("accessibility_2.png"))?), - tray_explain_image: Some(extract_icon(MAC_STATUS_ICON_EXPLAIN_IMAGE, &runtime_dir.join("icon_explain_image.png"))?), + logo_no_background: Some(extract_icon( + LOGO_NO_BACKGROUND_BINARY, + &runtime_dir.join("icon_no_background.png"), + )?), + accessibility_image_1: Some(extract_icon( + MAC_ACCESSIBILITY_1_BINARY, + &runtime_dir.join("accessibility_1.png"), + )?), + accessibility_image_2: Some(extract_icon( + MAC_ACCESSIBILITY_2_BINARY, + &runtime_dir.join("accessibility_2.png"), + )?), + tray_explain_image: Some(extract_icon( + MAC_STATUS_ICON_EXPLAIN_IMAGE, + &runtime_dir.join("icon_explain_image.png"), + )?), ..Default::default() }) } @@ -101,7 +136,10 @@ pub fn load_icon_paths(runtime_dir: &Path) -> Result { Ok(IconPaths { logo: Some(extract_icon(ICON_BINARY, &runtime_dir.join("iconv2.png"))?), search_icon: Some(extract_icon(ICON_BINARY, &runtime_dir.join("search.png"))?), - logo_no_background: Some(extract_icon(LOGO_NO_BACKGROUND_BINARY, &runtime_dir.join("icon_no_background.png"))?), + logo_no_background: Some(extract_icon( + LOGO_NO_BACKGROUND_BINARY, + &runtime_dir.join("icon_no_background.png"), + )?), ..Default::default() }) } diff --git a/espanso/src/ipc.rs b/espanso/src/ipc.rs index 418ec36..4d157d4 100644 --- a/espanso/src/ipc.rs +++ b/espanso/src/ipc.rs @@ -18,9 +18,9 @@ */ use anyhow::Result; -use espanso_ipc::{IPCServer, IPCClient}; +use espanso_ipc::{IPCClient, IPCServer}; +use serde::{Deserialize, Serialize}; use std::path::Path; -use serde::{Serialize, Deserialize}; #[derive(Debug, Serialize, Deserialize)] pub enum IPCEvent { @@ -40,15 +40,11 @@ pub fn create_ipc_client_to_worker(runtime_dir: &Path) -> Result Result> { +fn create_ipc_server(runtime_dir: &Path, name: &str) -> Result> { espanso_ipc::server(&format!("espanso{}", name), runtime_dir) } - fn create_ipc_client(runtime_dir: &Path, target_process: &str) -> Result> { let client = espanso_ipc::client(&format!("espanso{}", target_process), runtime_dir)?; Ok(client) -} \ No newline at end of file +} diff --git a/espanso/src/lock.rs b/espanso/src/lock.rs index 2076ae4..ee2dc2e 100644 --- a/espanso/src/lock.rs +++ b/espanso/src/lock.rs @@ -42,8 +42,12 @@ impl Lock { .write(true) .create(true) .open(&lock_file_path) - .unwrap_or_else(|_| panic!("unable to create reference to lock file: {:?}", - lock_file_path)); + .unwrap_or_else(|_| { + panic!( + "unable to create reference to lock file: {:?}", + lock_file_path + ) + }); if lock_file.try_lock_exclusive().is_ok() { Some(Lock { lock_file }) diff --git a/espanso/src/logging/mod.rs b/espanso/src/logging/mod.rs index f4859af..8f07067 100644 --- a/espanso/src/logging/mod.rs +++ b/espanso/src/logging/mod.rs @@ -76,12 +76,8 @@ impl Write for FileProxy { Ok(mut lock) => { match &mut (*lock) { // Write to the memory buffer until a file is ready - Output::Memory(buffer) => { - buffer.write(buf) - } - Output::File(output) => { - output.write(buf) - } + Output::Memory(buffer) => buffer.write(buf), + Output::File(output) => output.write(buf), } } Err(_) => Err(std::io::Error::new( @@ -93,16 +89,10 @@ impl Write for FileProxy { fn flush(&mut self) -> std::io::Result<()> { match self.output.lock() { - Ok(mut lock) => { - match &mut (*lock) { - Output::Memory(buffer) => { - buffer.flush() - } - Output::File(output) => { - output.flush() - } - } - } + Ok(mut lock) => match &mut (*lock) { + Output::Memory(buffer) => buffer.flush(), + Output::File(output) => output.flush(), + }, Err(_) => Err(std::io::Error::new( std::io::ErrorKind::Other, "lock poison error", @@ -133,4 +123,4 @@ macro_rules! error_eprintln { eprintln!($($tts)*); log::error!($($tts)*); } -} \ No newline at end of file +} diff --git a/espanso/src/main.rs b/espanso/src/main.rs index 0772c55..c005612 100644 --- a/espanso/src/main.rs +++ b/espanso/src/main.rs @@ -478,10 +478,7 @@ fn main() { )]; if !handler.disable_logs_terminal_output { - outputs.insert( - 0, - TermLogger::new(log_level, config, TerminalMode::Mixed), - ); + outputs.insert(0, TermLogger::new(log_level, config, TerminalMode::Mixed)); } CombinedLogger::init(outputs).expect("unable to initialize logs"); diff --git a/espanso/src/patch/mod.rs b/espanso/src/patch/mod.rs index 94a1ca3..3582aae 100644 --- a/espanso/src/patch/mod.rs +++ b/espanso/src/patch/mod.rs @@ -62,4 +62,4 @@ pub struct PatchDefinition { pub is_enabled: fn() -> bool, pub should_patch: fn(app: &AppProperties) -> bool, pub apply: fn(config: Arc, name: &str) -> Arc, -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/alacritty_terminal_x11.rs b/espanso/src/patch/patches/linux/alacritty_terminal_x11.rs index 175464f..f02ea34 100644 --- a/espanso/src/patch/patches/linux/alacritty_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/alacritty_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/emacs_x11.rs b/espanso/src/patch/patches/linux/emacs_x11.rs index 2a7fb72..c78bdae 100644 --- a/espanso/src/patch/patches/linux/emacs_x11.rs +++ b/espanso/src/patch/patches/linux/emacs_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/generic_terminal_x11.rs b/espanso/src/patch/patches/linux/generic_terminal_x11.rs index 4b0dd13..f0a60cb 100644 --- a/espanso/src/patch/patches/linux/generic_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/generic_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/kitty_terminal_x11.rs b/espanso/src/patch/patches/linux/kitty_terminal_x11.rs index 7a97e66..f57f041 100644 --- a/espanso/src/patch/patches/linux/kitty_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/kitty_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/konsole_terminal_x11.rs b/espanso/src/patch/patches/linux/konsole_terminal_x11.rs index 502e6f2..5922eeb 100644 --- a/espanso/src/patch/patches/linux/konsole_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/konsole_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/libreoffice_writer_x11.rs b/espanso/src/patch/patches/linux/libreoffice_writer_x11.rs index 4b20d76..4307b15 100644 --- a/espanso/src/patch/patches/linux/libreoffice_writer_x11.rs +++ b/espanso/src/patch/patches/linux/libreoffice_writer_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/mod.rs b/espanso/src/patch/patches/linux/mod.rs index bfb9379..6dd311b 100644 --- a/espanso/src/patch/patches/linux/mod.rs +++ b/espanso/src/patch/patches/linux/mod.rs @@ -23,8 +23,8 @@ pub mod generic_terminal_x11; pub mod kitty_terminal_x11; pub mod konsole_terminal_x11; pub mod libreoffice_writer_x11; -pub mod simple_terminal_x11; pub mod simple_terminal_2_x11; +pub mod simple_terminal_x11; pub mod terminator_terminal_x11; pub mod termite_terminal_x11; pub mod tilix_terminal_x11; @@ -32,4 +32,4 @@ pub mod urxvt_terminal_x11; pub mod xterm_terminal_x11; pub mod yakuake_terminal_x11; -mod util; \ No newline at end of file +mod util; diff --git a/espanso/src/patch/patches/linux/simple_terminal_2_x11.rs b/espanso/src/patch/patches/linux/simple_terminal_2_x11.rs index 8a27e23..2327add 100644 --- a/espanso/src/patch/patches/linux/simple_terminal_2_x11.rs +++ b/espanso/src/patch/patches/linux/simple_terminal_2_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/simple_terminal_x11.rs b/espanso/src/patch/patches/linux/simple_terminal_x11.rs index c0d704f..87c5fe7 100644 --- a/espanso/src/patch/patches/linux/simple_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/simple_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/terminator_terminal_x11.rs b/espanso/src/patch/patches/linux/terminator_terminal_x11.rs index a8132f0..e6ab86a 100644 --- a/espanso/src/patch/patches/linux/terminator_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/terminator_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/termite_terminal_x11.rs b/espanso/src/patch/patches/linux/termite_terminal_x11.rs index 464796b..6e412c5 100644 --- a/espanso/src/patch/patches/linux/termite_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/termite_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/tilix_terminal_x11.rs b/espanso/src/patch/patches/linux/tilix_terminal_x11.rs index 0128f8b..3b205f3 100644 --- a/espanso/src/patch/patches/linux/tilix_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/tilix_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/urxvt_terminal_x11.rs b/espanso/src/patch/patches/linux/urxvt_terminal_x11.rs index 54813ec..f09e51a 100644 --- a/espanso/src/patch/patches/linux/urxvt_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/urxvt_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/util.rs b/espanso/src/patch/patches/linux/util.rs index 4c261cc..0a6b28f 100644 --- a/espanso/src/patch/patches/linux/util.rs +++ b/espanso/src/patch/patches/linux/util.rs @@ -19,4 +19,4 @@ pub fn is_wayland() -> bool { cfg!(feature = "wayland") -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/linux/yakuake_terminal_x11.rs b/espanso/src/patch/patches/linux/yakuake_terminal_x11.rs index d07ebe8..31c6a9e 100644 --- a/espanso/src/patch/patches/linux/yakuake_terminal_x11.rs +++ b/espanso/src/patch/patches/linux/yakuake_terminal_x11.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/macros.rs b/espanso/src/patch/patches/macros.rs index 21d8d46..c89c4ac 100644 --- a/espanso/src/patch/patches/macros.rs +++ b/espanso/src/patch/patches/macros.rs @@ -96,4 +96,4 @@ macro_rules! generate_patchable_config { } } }; -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/mod.rs b/espanso/src/patch/patches/mod.rs index 4bee72f..5fddc89 100644 --- a/espanso/src/patch/patches/mod.rs +++ b/espanso/src/patch/patches/mod.rs @@ -16,7 +16,7 @@ * You should have received a copy of the GNU General Public License * along with espanso. If not, see . */ - + use espanso_config::config::{Backend, RMLVOConfig, ToggleKey}; #[cfg(target_os = "windows")] diff --git a/espanso/src/patch/patches/win/mod.rs b/espanso/src/patch/patches/win/mod.rs index 6988331..63fb862 100644 --- a/espanso/src/patch/patches/win/mod.rs +++ b/espanso/src/patch/patches/win/mod.rs @@ -18,4 +18,4 @@ */ pub mod onenote_for_windows_10; -pub mod vscode_win; \ No newline at end of file +pub mod vscode_win; diff --git a/espanso/src/patch/patches/win/onenote_for_windows_10.rs b/espanso/src/patch/patches/win/onenote_for_windows_10.rs index 478c28a..f1a5db7 100644 --- a/espanso/src/patch/patches/win/onenote_for_windows_10.rs +++ b/espanso/src/patch/patches/win/onenote_for_windows_10.rs @@ -38,4 +38,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/patch/patches/win/vscode_win.rs b/espanso/src/patch/patches/win/vscode_win.rs index da1a009..c080dee 100644 --- a/espanso/src/patch/patches/win/vscode_win.rs +++ b/espanso/src/patch/patches/win/vscode_win.rs @@ -41,4 +41,4 @@ pub fn patch() -> PatchDefinition { )) }, } -} \ No newline at end of file +} diff --git a/espanso/src/path/linux.rs b/espanso/src/path/linux.rs index ae450ac..29a27c2 100644 --- a/espanso/src/path/linux.rs +++ b/espanso/src/path/linux.rs @@ -18,7 +18,7 @@ */ use anyhow::Result; -use std::{path::PathBuf}; +use std::path::PathBuf; use thiserror::Error; pub fn is_espanso_in_path() -> bool { diff --git a/espanso/src/path/macos.rs b/espanso/src/path/macos.rs index 729cea9..58f020a 100644 --- a/espanso/src/path/macos.rs +++ b/espanso/src/path/macos.rs @@ -50,11 +50,10 @@ pub fn add_espanso_to_path(prompt_when_necessary: bool) -> Result<()> { target_link_path.to_string_lossy(), ); - let mut child = std::process::Command::new("osascript").args(&[ - "-e", - ¶ms, - ]).spawn()?; - + let mut child = std::process::Command::new("osascript") + .args(&["-e", ¶ms]) + .spawn()?; + let result = child.wait()?; if !result.success() { return Err(PathError::ElevationRequestFailure.into()); @@ -90,11 +89,10 @@ pub fn remove_espanso_from_path(prompt_when_necessary: bool) -> Result<()> { target_link_path.to_string_lossy(), ); - let mut child = std::process::Command::new("osascript").args(&[ - "-e", - ¶ms, - ]).spawn()?; - + let mut child = std::process::Command::new("osascript") + .args(&["-e", ¶ms]) + .spawn()?; + let result = child.wait()?; if !result.success() { return Err(PathError::ElevationRequestFailure.into()); @@ -119,7 +117,7 @@ pub enum PathError { #[error("symlink error: `{0}`")] SymlinkError(std::io::Error), - + #[error("elevation request failed")] ElevationRequestFailure, diff --git a/espanso/src/path/mod.rs b/espanso/src/path/mod.rs index 0a91140..4278155 100644 --- a/espanso/src/path/mod.rs +++ b/espanso/src/path/mod.rs @@ -22,24 +22,24 @@ mod macos; #[cfg(target_os = "macos")] pub use macos::add_espanso_to_path; #[cfg(target_os = "macos")] -pub use macos::remove_espanso_from_path; -#[cfg(target_os = "macos")] pub use macos::is_espanso_in_path; +#[cfg(target_os = "macos")] +pub use macos::remove_espanso_from_path; #[cfg(target_os = "windows")] mod win; #[cfg(target_os = "windows")] pub use win::add_espanso_to_path; #[cfg(target_os = "windows")] -pub use win::remove_espanso_from_path; -#[cfg(target_os = "windows")] pub use win::is_espanso_in_path; +#[cfg(target_os = "windows")] +pub use win::remove_espanso_from_path; #[cfg(target_os = "linux")] mod linux; #[cfg(target_os = "linux")] pub use linux::add_espanso_to_path; #[cfg(target_os = "linux")] -pub use linux::remove_espanso_from_path; -#[cfg(target_os = "linux")] pub use linux::is_espanso_in_path; +#[cfg(target_os = "linux")] +pub use linux::remove_espanso_from_path; diff --git a/espanso/src/preferences/default.rs b/espanso/src/preferences/default.rs index 5218c8d..e7747c1 100644 --- a/espanso/src/preferences/default.rs +++ b/espanso/src/preferences/default.rs @@ -72,7 +72,9 @@ impl Preferences for DefaultPreferences { } fn should_display_troubleshoot_for_non_fatal_errors(&self) -> bool { - self.get(SHOULD_DISPLAY_TROUBLESHOOT_FOR_NON_FATAL_ERRORS).unwrap_or(true) + self + .get(SHOULD_DISPLAY_TROUBLESHOOT_FOR_NON_FATAL_ERRORS) + .unwrap_or(true) } fn set_should_display_troubleshoot_for_non_fatal_errors(&self, value: bool) { diff --git a/espanso/src/preferences/mod.rs b/espanso/src/preferences/mod.rs index 8452546..569fb37 100644 --- a/espanso/src/preferences/mod.rs +++ b/espanso/src/preferences/mod.rs @@ -17,8 +17,8 @@ * along with espanso. If not, see . */ -use std::path::Path; use anyhow::Result; +use std::path::Path; mod default; @@ -36,4 +36,4 @@ pub trait Preferences: Send + Sync + Clone { pub fn get_default(runtime_dir: &Path) -> Result { let kvs = espanso_kvs::get_persistent(runtime_dir)?; default::DefaultPreferences::new(kvs) -} \ No newline at end of file +} diff --git a/espanso/src/util.rs b/espanso/src/util.rs index d5bea46..1e4a22f 100644 --- a/espanso/src/util.rs +++ b/espanso/src/util.rs @@ -42,4 +42,4 @@ pub fn attach_console() { #[cfg(not(target_os = "windows"))] pub fn attach_console() { // Not necessary on Linux and macOS -} \ No newline at end of file +}