plugins/applications: fix terminal apps with arguments
This commit is contained in:
@@ -31,6 +31,16 @@ mod scrubber;
|
|||||||
|
|
||||||
const SENSIBLE_TERMINALS: &[&str] = &["alacritty", "foot", "kitty", "wezterm", "wterm"];
|
const SENSIBLE_TERMINALS: &[&str] = &["alacritty", "foot", "kitty", "wezterm", "wterm"];
|
||||||
|
|
||||||
|
// remove arguments since they're not being used
|
||||||
|
// https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html
|
||||||
|
fn sanitize_exec(exec: &String) -> String {
|
||||||
|
exec.replace("%U", "")
|
||||||
|
.replace("%F", "")
|
||||||
|
.replace("%u", "")
|
||||||
|
.replace("%f", "")
|
||||||
|
.replace(" ", "")
|
||||||
|
}
|
||||||
|
|
||||||
#[handler]
|
#[handler]
|
||||||
pub fn handler(selection: Match, state: &State) -> HandleResult {
|
pub fn handler(selection: Match, state: &State) -> HandleResult {
|
||||||
let entry = state
|
let entry = state
|
||||||
@@ -45,21 +55,18 @@ pub fn handler(selection: Match, state: &State) -> HandleResult {
|
|||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
let exec = sanitize_exec(&entry.exec);
|
||||||
|
|
||||||
if entry.term {
|
if entry.term {
|
||||||
match &state.config.terminal {
|
match &state.config.terminal {
|
||||||
Some(term) => {
|
Some(term) => {
|
||||||
if let Err(why) = Command::new(term).arg("-e").arg(&entry.exec).spawn() {
|
if let Err(why) = Command::new(term).arg("-e").arg(&exec).spawn() {
|
||||||
eprintln!("Error running desktop entry: {}", why);
|
eprintln!("Error running desktop entry: {}", why);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
for term in SENSIBLE_TERMINALS {
|
for term in SENSIBLE_TERMINALS {
|
||||||
if Command::new(term)
|
if Command::new(term).arg("-e").arg(&exec).spawn().is_ok() {
|
||||||
.arg("-e")
|
|
||||||
.arg(&entry.exec)
|
|
||||||
.spawn()
|
|
||||||
.is_ok()
|
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user