Support launching app in terminal
- Get terminal setting from desktop file - Launch app in terminal if set
This commit is contained in:
parent
1914006cdd
commit
4d3d283f52
1 changed files with 24 additions and 9 deletions
|
|
@ -62,6 +62,7 @@ pub struct DesktopEntryData {
|
||||||
pub desktop_actions: Vec<DesktopAction>,
|
pub desktop_actions: Vec<DesktopAction>,
|
||||||
pub mime_types: Vec<Mime>,
|
pub mime_types: Vec<Mime>,
|
||||||
pub prefers_dgpu: bool,
|
pub prefers_dgpu: bool,
|
||||||
|
pub terminal: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
|
|
@ -233,13 +234,18 @@ impl DesktopEntryData {
|
||||||
})
|
})
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
prefers_dgpu: de.prefers_non_default_gpu(),
|
prefers_dgpu: de.prefers_non_default_gpu(),
|
||||||
|
terminal: de.terminal(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
pub async fn spawn_desktop_exec<S, I, K, V>(exec: S, env_vars: I, app_id: Option<&str>)
|
pub async fn spawn_desktop_exec<S, I, K, V>(
|
||||||
where
|
exec: S,
|
||||||
|
env_vars: I,
|
||||||
|
app_id: Option<&str>,
|
||||||
|
terminal: bool,
|
||||||
|
) where
|
||||||
S: AsRef<str>,
|
S: AsRef<str>,
|
||||||
I: IntoIterator<Item = (K, V)>,
|
I: IntoIterator<Item = (K, V)>,
|
||||||
K: AsRef<OsStr>,
|
K: AsRef<OsStr>,
|
||||||
|
|
@ -252,14 +258,23 @@ where
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let mut cmd = match terminal {
|
||||||
|
true => {
|
||||||
|
let mut cmd = std::process::Command::new("cosmic-term");
|
||||||
|
cmd.args(vec!["--", format!("{}", &executable).as_str()]);
|
||||||
|
cmd
|
||||||
|
}
|
||||||
|
false => {
|
||||||
let mut cmd = std::process::Command::new(&executable);
|
let mut cmd = std::process::Command::new(&executable);
|
||||||
|
|
||||||
for arg in exec {
|
for arg in exec {
|
||||||
// TODO handle "%" args here if necessary?
|
// TODO handle "%" args here if necessary?
|
||||||
if !arg.starts_with('%') {
|
if !arg.starts_with('%') {
|
||||||
cmd.arg(arg);
|
cmd.arg(arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
cmd
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
cmd.envs(env_vars);
|
cmd.envs(env_vars);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue