Skip to content

Commit ae4dfa7

Browse files
committed
feat(macos/indexing):
we can now have customs paths to index and file exe's from, perhaps in the future we could accept globals in the array..
1 parent 9f526e2 commit ae4dfa7

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

src/utils.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use image::RgbaImage;
1212

1313
use crate::{app::App, commands::Function};
1414
#[cfg(target_os = "macos")]
15-
use {crate::macos::get_installed_macos_apps, objc2_app_kit::NSWorkspace, objc2_foundation::NSURL};
15+
use {
16+
crate::macos::get_installed_macos_apps, objc2_app_kit::NSWorkspace, objc2_foundation::NSURL,
17+
std::os::unix::fs::PermissionsExt,
18+
};
1619
#[cfg(target_os = "windows")]
1720
use {crate::windows::get_installed_windows_apps, std::process::Command};
1821

@@ -280,7 +283,17 @@ pub fn index_dirs_from_config(apps: &mut Vec<App>) -> bool {
280283
let path = path.unwrap().path();
281284
let metadata = fs::metadata(&path).unwrap();
282285

283-
if metadata.is_file() && Path::new(&path).extension().unwrap() == "exe" {
286+
#[cfg(target_os = "windows")]
287+
let is_executable =
288+
metadata.is_file() && path.extension().and_then(|s| s.to_str()) == Some("exe");
289+
290+
#[cfg(target_os = "macos")]
291+
let is_executable = {
292+
(metadata.is_file() && (metadata.permissions().mode() & 0o111 != 0))
293+
|| path.extension().and_then(|s| s.to_str()) == Some("app")
294+
};
295+
296+
if is_executable {
284297
let display_name = path.file_name().unwrap().to_string_lossy().to_string();
285298
apps.push(App {
286299
open_command: Function::OpenApp(path.to_string_lossy().to_string()),

0 commit comments

Comments
 (0)