diff --git a/espanso/src/cli/launcher/mod.rs b/espanso/src/cli/launcher/mod.rs
index fc0f3bd..ad354ca 100644
--- a/espanso/src/cli/launcher/mod.rs
+++ b/espanso/src/cli/launcher/mod.rs
@@ -34,6 +34,7 @@ pub fn new() -> CliModule {
requires_paths: true,
enable_logs: false,
subcommand: "launcher".to_string(),
+ show_in_dock: true,
entry: launcher_main,
..Default::default()
}
@@ -163,6 +164,12 @@ fn launcher_main(args: CliModuleArgs) -> i32 {
// TODO: initialize config directory if not present
if should_launch_daemon {
+ // We hide the dock icon on macOS to avoid having it around when the daemon is running
+ #[cfg(target_os = "macos")]
+ {
+ espanso_mac_utils::convert_to_background_app();
+ }
+
daemon::launch_daemon(&paths_overrides).expect("failed to launch daemon");
}
diff --git a/espanso/src/cli/mod.rs b/espanso/src/cli/mod.rs
index bf0ec74..7166f04 100644
--- a/espanso/src/cli/mod.rs
+++ b/espanso/src/cli/mod.rs
@@ -39,6 +39,7 @@ pub struct CliModule {
pub requires_paths: bool,
pub requires_config: bool,
pub subcommand: String,
+ pub show_in_dock: bool,
pub entry: fn(CliModuleArgs)->i32,
}
@@ -51,6 +52,7 @@ impl Default for CliModule {
requires_paths: false,
requires_config: false,
subcommand: "".to_string(),
+ show_in_dock: false,
entry: |_| {0},
}
}
diff --git a/espanso/src/main.rs b/espanso/src/main.rs
index 76110bc..28fe541 100644
--- a/espanso/src/main.rs
+++ b/espanso/src/main.rs
@@ -377,6 +377,14 @@ fn main() {
log_panics::init();
}
+ // If explicitly requested, we show the Dock icon on macOS
+ // We need to enable this selectively, otherwise we would end up with multiple
+ // dock icons due to the multi-process nature of espanso.
+ #[cfg(target_os = "macos")]
+ if handler.show_in_dock {
+ espanso_mac_utils::convert_to_foreground_app();
+ }
+
let mut cli_args: CliModuleArgs = CliModuleArgs::default();
if handler.requires_paths || handler.requires_config {
diff --git a/espanso/src/res/macos/Info.plist b/espanso/src/res/macos/Info.plist
index d55fe99..340a164 100644
--- a/espanso/src/res/macos/Info.plist
+++ b/espanso/src/res/macos/Info.plist
@@ -37,5 +37,7 @@
Copyright 2019-2021 Federico Terzi
LSRequiresCarbon
+ LSUIElement
+ 1