feat(core): improve icon dock handling on macOS
This commit is contained in:
		
							parent
							
								
									ddf8a35aeb
								
							
						
					
					
						commit
						4ee1215fbc
					
				| 
						 | 
				
			
			@ -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");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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},
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,5 +37,7 @@
 | 
			
		|||
	<string>Copyright 2019-2021 Federico Terzi</string>
 | 
			
		||||
	<key>LSRequiresCarbon</key>
 | 
			
		||||
	<true/>
 | 
			
		||||
	<key>LSUIElement</key>
 | 
			
		||||
	<string>1</string>
 | 
			
		||||
</dict>
 | 
			
		||||
</plist>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user