mirror of
https://github.com/chmln/handlr.git
synced 2024-11-14 13:39:29 +01:00
Merge pull request #18 from ftilde/master
Launch process in terminal emulator if required
This commit is contained in:
commit
47b638fcdf
2 changed files with 14 additions and 0 deletions
|
@ -70,6 +70,18 @@ impl DesktopEntry {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// If the entry expects a terminal (emulator), but this process is not running in one, we
|
||||
// launch a new one.
|
||||
if self.term && !atty::is(atty::Stream::Stdout) {
|
||||
let config = crate::config::Config::load()?;
|
||||
let terminal_emulator_args =
|
||||
shlex::split(&config.terminal_emulator).unwrap();
|
||||
split = terminal_emulator_args
|
||||
.into_iter()
|
||||
.chain(split.into_iter())
|
||||
.collect();
|
||||
}
|
||||
|
||||
Ok((split.remove(0), split))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
|
|||
pub struct Config {
|
||||
pub enable_selector: bool,
|
||||
pub selector: String,
|
||||
pub terminal_emulator: String,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
|
@ -12,6 +13,7 @@ impl Default for Config {
|
|||
Config {
|
||||
enable_selector: false,
|
||||
selector: "rofi -dmenu -p 'Open With: '".to_owned(),
|
||||
terminal_emulator: "xterm -e".to_owned(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue