Inject user path in Plist file when registering on macOS. Fix #233
This commit is contained in:
		
							parent
							
								
									232e80f55a
								
							
						
					
					
						commit
						470f8d6221
					
				| 
						 | 
				
			
			@ -4,6 +4,11 @@
 | 
			
		|||
<dict>
 | 
			
		||||
    <key>Label</key>
 | 
			
		||||
    <string>com.federicoterzi.espanso</string>
 | 
			
		||||
    <key>EnvironmentVariables</key>
 | 
			
		||||
    <dict>
 | 
			
		||||
        <key>PATH</key>
 | 
			
		||||
        <string>{{{PATH}}}</string>
 | 
			
		||||
    </dict>
 | 
			
		||||
    <key>ProgramArguments</key>
 | 
			
		||||
    <array>
 | 
			
		||||
        <string>{{{espanso_path}}}</string>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,6 +61,12 @@ pub fn register(_config_set: ConfigSet) {
 | 
			
		|||
            espanso_path.to_str().unwrap_or_default(),
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        // Copy the user PATH variable and inject it in the Plist file so that
 | 
			
		||||
        // it gets loaded by Launchd.
 | 
			
		||||
        // To see why this is necessary: https://github.com/federico-terzi/espanso/issues/233
 | 
			
		||||
        let user_path = std::env::var("PATH").unwrap_or("".to_owned());
 | 
			
		||||
        let plist_content = plist_content.replace("{{{PATH}}}", &user_path);
 | 
			
		||||
 | 
			
		||||
        std::fs::write(plist_file.clone(), plist_content).expect("Unable to write plist file");
 | 
			
		||||
 | 
			
		||||
        println!("Entry created correctly!")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user