pub fn exec_entry(
entry: &DesktopEntry<'_>,
detach: bool,
) -> Result<Option<ExitStatus>>Expand description
Attempts to execute the program within a desktop entry. The executed program will be detached from the terminal if ‘detach’ is true.
§Returns
If execution is successful and the program is not detached, the ‘ExitStatus’ of the executed program will be returned.
§Examples
use desk_exec::exec_entry;
use freedesktop_desktop_entry::DesktopEntry;
let entry = DesktopEntry::from_appid("example_appid");
match exec_entry(&entry, false) {
Ok(Some(exit_status)) => {
eprintln!("Program executed with code: '{}'", exit_status.code().unwrap_or_default());
}
Ok(None) => {
eprintln!("Program executed with no exit code.");
}
Err(_) => {
eprintln!("Program failed to execute.");
}
}