pop-os / launcher

Modular IPC-based desktop launcher service
Mozilla Public License 2.0
228 stars 47 forks source link

Setting an alternate terminal for plugin does not work #33

Closed oknozor closed 2 years ago

oknozor commented 2 years ago

Description

Running a terminal plugin command with a custom terminal launch the command with the default gnome-terminal instead.

Reproduce

  1. Set a symlink to an alternate terminal : /usr/bin/x-terminal-emulator -> /usr/bin/alacritty
  2. Activate the following pop response search result :
    
    Ok(Update([SearchResult { id: 0, name: "run echo toto", description: "run command in terminal", icon: None, category_icon: Some(Name("utilities-terminal")), window: None }]))

{\"Activate\":0} // Send the activate request


### Additional context

OS: archlinux
pop-launcher version: `1.0.1`
front-end: [onagre](https://github.com/oknozor/onagre/tree/feat/pop-launcher-backend)

I have tried this with several terminal emulator (xterm, tilix, termite, alacritty).
I am missing something obvious here or is this actually not working as expected ? 

**Edit** : I think this happens because the `detect_terminal` function is trying to resolve the symlink twice : 
```rust
fn detect_terminal() -> (PathBuf, &'static str) {
    use std::fs::read_link;

    const SYMLINK: &str = "/usr/bin/x-terminal-emulator";

    if let Ok(found) = read_link(SYMLINK) { // `Ok("/usr/bin/alacritty")` 
        if let Ok(found) = read_link(&found) { // `Err(Os { code: 22, kind: InvalidInput, message: "Invalid argument" })`
            return (found, "-e");
        }
    }

    (PathBuf::from("/usr/bin/gnome-terminal"), "--")
}