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
This commit is contained in:
BennyDioxide
2024-04-03 17:27:56 +08:00
committed by GitHub
parent e14da6c373
commit cda1ab4395

View File

@@ -65,11 +65,19 @@ pub fn handler(selection: Match, state: &State) -> HandleResult {
}
}
}
} else if let Err(why) = Command::new("sh")
.arg("-c")
.arg(&entry.exec)
.current_dir(entry.path.as_ref().unwrap_or(&env::current_dir().unwrap()))
.spawn()
} else if let Err(why) = {
let current_dir = &env::current_dir().unwrap();
Command::new("sh")
.arg("-c")
.arg(&entry.exec)
.current_dir(if let Some(path) = &entry.path {
if path.exists() { path } else { current_dir }
} else {
current_dir
})
.spawn()
}
{
eprintln!("Error running desktop entry: {}", why);
}