git.lucas.co / cce-files
file manager
git clone https://git.lucas.co/cce-files.git

commitb642a678395de9bb1d410c35869fd542d2466f5f
parentb8c5fd5036
authorLucas Galante <[email protected]>
date2026-06-29 15:22
Resolve command path to ~/.local/bin fallback if not absolute

 src/main.rs        | 11 ++++++++++-
 src/services/fs.rs | 24 +++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 85ca716..c77345d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -773,7 +773,16 @@ impl Application for FilesystemApp {
                         let parts: Vec<&str> = cmd_str.split_whitespace().collect();
                         if !parts.is_empty() {
                             let program = parts[0];
-                            let mut command = std::process::Command::new(program);
+                            let mut program_path = std::path::PathBuf::from(program);
+                            if !program_path.is_absolute() && !program.contains('/') {
+                                if let Ok(home) = std::env::var("HOME") {
+                                    let local_bin = std::path::PathBuf::from(home).join(".local").join("bin").join(program);
+                                    if local_bin.exists() {
+                                        program_path = local_bin;
+                                    }
+                                }
+                            }
+                            let mut command = std::process::Command::new(program_path);
                             for arg in &parts[1..] {
                                 command.arg(arg);
                             }
diff --git a/src/services/fs.rs b/src/services/fs.rs
index 16e49b1..1290f72 100644
--- a/src/services/fs.rs
+++ b/src/services/fs.rs
@@ -522,7 +522,16 @@ pub fn open_file(path: &Path) {
                 let parts: Vec<&str> = cmd.split_whitespace().collect();
                 if !parts.is_empty() {
                     let program = parts[0];
-                    let mut command = std::process::Command::new(program);
+                    let mut program_path = PathBuf::from(program);
+                    if !program_path.is_absolute() && !program.contains('/') {
+                        if let Ok(home) = std::env::var("HOME") {
+                            let local_bin = PathBuf::from(home).join(".local").join("bin").join(program);
+                            if local_bin.exists() {
+                                program_path = local_bin;
+                            }
+                        }
+                    }
+                    let mut command = std::process::Command::new(program_path);
                     for arg in &parts[1..] {
                         command.arg(arg);
                     }
@@ -541,4 +550,17 @@ pub fn open_file(path: &Path) {
     }
 }
 
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_kdl() {
+        let assoc = load_kdl_associations();
+        println!("Parsed associations: {:?}", assoc);
+        assert!(assoc.is_some());
+    }
+}
+
+