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.

Cross compilation hopefully

+58 -44
+11
.cargo/config.toml
··· 1 + [target.aarch64-apple-darwin] 2 + rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"] 3 + 4 + [target.x86_64-apple-darwin] 5 + rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"] 6 + 7 + [target.x86_64-unknown-linux-musl] 8 + linker = "x86_64-linux-musl-gcc" 9 + 10 + [target.aarch64-unknown-linux-musl] 11 + linker = "aarch64-linux-musl-gcc"
+35 -30
Cargo.lock
··· 98 98 checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" 99 99 100 100 [[package]] 101 - name = "block" 102 - version = "0.1.6" 101 + name = "bitflags" 102 + version = "2.11.0" 103 + source = "registry+https://github.com/rust-lang/crates.io-index" 104 + checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" 105 + 106 + [[package]] 107 + name = "block2" 108 + version = "0.5.1" 103 109 source = "registry+https://github.com/rust-lang/crates.io-index" 104 - checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" 110 + checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" 111 + dependencies = [ 112 + "objc2", 113 + ] 105 114 106 115 [[package]] 107 116 name = "cfg-if" ··· 294 303 "dir_spec", 295 304 "eyre", 296 305 "libc", 297 - "objc", 298 - "objc-foundation", 306 + "objc2", 307 + "objc2-foundation", 299 308 "plist", 300 309 "serde", 301 310 "thiserror", ··· 333 342 version = "0.4.28" 334 343 source = "registry+https://github.com/rust-lang/crates.io-index" 335 344 checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" 336 - 337 - [[package]] 338 - name = "malloc_buf" 339 - version = "0.0.6" 340 - source = "registry+https://github.com/rust-lang/crates.io-index" 341 - checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" 342 - dependencies = [ 343 - "libc", 344 - ] 345 345 346 346 [[package]] 347 347 name = "matchers" ··· 393 393 checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" 394 394 395 395 [[package]] 396 - name = "objc" 397 - version = "0.2.7" 396 + name = "objc-sys" 397 + version = "0.3.5" 398 398 source = "registry+https://github.com/rust-lang/crates.io-index" 399 - checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" 400 - dependencies = [ 401 - "malloc_buf", 402 - ] 399 + checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" 403 400 404 401 [[package]] 405 - name = "objc-foundation" 406 - version = "0.1.1" 402 + name = "objc2" 403 + version = "0.5.2" 407 404 source = "registry+https://github.com/rust-lang/crates.io-index" 408 - checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" 405 + checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" 409 406 dependencies = [ 410 - "block", 411 - "objc", 412 - "objc_id", 407 + "objc-sys", 408 + "objc2-encode", 413 409 ] 414 410 415 411 [[package]] 416 - name = "objc_id" 417 - version = "0.1.1" 412 + name = "objc2-encode" 413 + version = "4.1.0" 414 + source = "registry+https://github.com/rust-lang/crates.io-index" 415 + checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" 416 + 417 + [[package]] 418 + name = "objc2-foundation" 419 + version = "0.2.2" 418 420 source = "registry+https://github.com/rust-lang/crates.io-index" 419 - checksum = "c92d4ddb4bd7b50d730c215ff871754d0da6b2178849f8a2a2ab69712d0c073b" 421 + checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" 420 422 dependencies = [ 421 - "objc", 423 + "bitflags", 424 + "block2", 425 + "libc", 426 + "objc2", 422 427 ] 423 428 424 429 [[package]]
+2 -2
infat-lib/Cargo.toml
··· 24 24 libc = "0.2" 25 25 26 26 # Objective-C bindings 27 - objc = "0.2" 28 - objc-foundation = "0.1" 27 + objc2 = "0.5" 28 + objc2-foundation = { version = "0.2", features = ["NSString"] }
+10 -12
infat-lib/src/macos/workspace.rs
··· 1 1 //! NSWorkspace integration for app discovery and management 2 2 3 3 use crate::error::{InfatError, Result}; 4 - use objc::{class, msg_send, runtime::Object, sel, sel_impl}; 5 - use objc_foundation::{INSString, NSString}; 4 + use objc2::{class, msg_send, rc::autoreleasepool, runtime::AnyObject}; 5 + use objc2_foundation::{self, NSString}; 6 6 use std::path::{Path, PathBuf}; 7 7 use tracing::debug; 8 8 9 - // Make a point of linking the AppKit framework 10 - #[link(name = "AppKit", kind = "framework")] 11 - extern "C" {} 12 - 13 9 /// Get the shared NSWorkspace instance 14 - unsafe fn shared_workspace() -> *mut Object { 10 + unsafe fn shared_workspace() -> *mut AnyObject { 15 11 let workspace_class = class!(NSWorkspace); 16 12 msg_send![workspace_class, sharedWorkspace] 17 13 } ··· 23 19 unsafe { 24 20 let workspace = shared_workspace(); 25 21 let ns_bundle_id = NSString::from_str(bundle_id); 26 - let cf_url: *mut Object = 27 - msg_send![workspace, URLForApplicationWithBundleIdentifier: ns_bundle_id]; 22 + let cf_url: *mut AnyObject = 23 + msg_send![workspace, URLForApplicationWithBundleIdentifier: &*ns_bundle_id]; 28 24 29 25 if cf_url.is_null() { 30 26 debug!("No application found for bundle ID: {}", bundle_id); ··· 32 28 } 33 29 34 30 let ns_path: *mut NSString = msg_send![cf_url, path]; 35 - let path_str = (*ns_path).as_str(); 36 - let path = PathBuf::from(path_str); 31 + let path = autoreleasepool(|pool| { 32 + let path_str = (*ns_path).as_str(pool); 33 + PathBuf::from(path_str) 34 + }); 37 35 38 36 debug!("Found app path for {}: {}", bundle_id, path.display()); 39 37 Ok(vec![path]) ··· 138 136 Path::new("/Applications").to_path_buf(), 139 137 Path::new("/System/Applications").to_path_buf(), 140 138 Path::new("/System/Library/CoreServices/Applications").to_path_buf(), 141 - Path::new(&std::env::var("HOME").unwrap_or_default()).join("Applications") 139 + Path::new(&std::env::var("HOME").unwrap_or_default()).join("Applications"), 142 140 ]; 143 141 144 142 let mut apps = Vec::new();