Skip to content

Commit

Permalink
Merge pull request #197 from fufexan/launch-prefix
Browse files Browse the repository at this point in the history
Revert "plugins/applications: fix terminal apps with arguments"
  • Loading branch information
NotAShelf authored Nov 8, 2024
2 parents b3b4f22 + 3c5b64e commit d2017f2
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions plugins/applications/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,6 @@ mod scrubber;

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]
pub fn handler(selection: Match, state: &State) -> HandleResult {
let entry = state
Expand All @@ -55,18 +45,21 @@ pub fn handler(selection: Match, state: &State) -> HandleResult {
})
.unwrap();

let exec = sanitize_exec(&entry.exec);

if entry.term {
match &state.config.terminal {
Some(term) => {
if let Err(why) = Command::new(term).arg("-e").arg(&exec).spawn() {
if let Err(why) = Command::new(term).arg("-e").arg(&entry.exec).spawn() {
eprintln!("Error running desktop entry: {}", why);
}
}
None => {
for term in SENSIBLE_TERMINALS {
if Command::new(term).arg("-e").arg(&exec).spawn().is_ok() {
if Command::new(term)
.arg("-e")
.arg(&entry.exec)
.spawn()
.is_ok()
{
break;
}
}
Expand Down

0 comments on commit d2017f2

Please sign in to comment.