desk_exec

Function exec_entry

Source
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

let entry = freedesktop_desktop_entry::DesktopEntry::from_appid("0");

match desk_exec::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 code.");
    }

    Err(_) => {
        eprintln!("Program failed to execute.");
    }
}