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