Skip to content

Commit cda1ab4

Browse files
authored
fix: Desktop Entries without proper path wouldn't run (#120)
* fix: Desktop Entries without proper path wouldn't run Now it would try to run in env::current_dir if the path was not set or not proper * refactor: Remove the empty `#![feature()]` attribute
1 parent e14da6c commit cda1ab4

File tree

1 file changed

+13
-5
lines changed
  • plugins/applications/src

1 file changed

+13
-5
lines changed

plugins/applications/src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,19 @@ pub fn handler(selection: Match, state: &State) -> HandleResult {
6565
}
6666
}
6767
}
68-
} else if let Err(why) = Command::new("sh")
69-
.arg("-c")
70-
.arg(&entry.exec)
71-
.current_dir(entry.path.as_ref().unwrap_or(&env::current_dir().unwrap()))
72-
.spawn()
68+
} else if let Err(why) = {
69+
let current_dir = &env::current_dir().unwrap();
70+
71+
Command::new("sh")
72+
.arg("-c")
73+
.arg(&entry.exec)
74+
.current_dir(if let Some(path) = &entry.path {
75+
if path.exists() { path } else { current_dir }
76+
} else {
77+
current_dir
78+
})
79+
.spawn()
80+
}
7381
{
7482
eprintln!("Error running desktop entry: {}", why);
7583
}

0 commit comments

Comments
 (0)