Connect applications to schemes, filetypes, and more on macOS (more to come)
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Relying on a match from supertypes before calling it and matching dynamically

Pretty sure that the official labeled ones supercede whatever launch
services gives

+9 -4
+9 -4
infat-lib/src/association.rs
··· 6 6 use tracing::{debug, info}; 7 7 8 8 /// Set the default application for a file extension 9 - pub fn set_default_app_for_extension(extension: &str, app_name: &str) -> Result<()> { 9 + pub fn set_default_app_for_extension(extension: &str, app_name: &str) -> Result<()> { 10 10 info!( 11 11 "Setting default app for extension .{} to {}", 12 12 extension, app_name ··· 19 19 } 20 20 21 21 // Get the UTI for the extension 22 - let uti = launch_services::get_uti_for_extension(extension)?; 22 + let supertype: Result<SuperType> = extension.parse(); 23 + 24 + let uti = match supertype { 25 + Ok(val) => val.uti_string().to_string(), 26 + Err(_) => launch_services::get_uti_for_extension(extension)?, 27 + }; 23 28 debug!("Extension .{} maps to UTI: {}", extension, uti); 24 29 25 30 // Resolve app name to bundle ID ··· 33 38 } 34 39 35 40 /// Set the default application for a URL scheme 36 - pub fn set_default_app_for_url_scheme(scheme: &str, app_name: &str) -> Result<()> { 41 + pub fn set_default_app_for_url_scheme(scheme: &str, app_name: &str) -> Result<()> { 37 42 info!( 38 43 "Setting default app for URL scheme {} to {}", 39 44 scheme, app_name ··· 63 68 } 64 69 65 70 /// Set the default application for a supertype/UTI 66 - pub fn set_default_app_for_type(type_name: &str, app_name: &str) -> Result<()> { 71 + pub fn set_default_app_for_type(type_name: &str, app_name: &str) -> Result<()> { 67 72 info!("Setting default app for type {} to {}", type_name, app_name); 68 73 69 74 // Handle special routing for web types