mirror of
https://github.com/chmln/handlr.git
synced 2024-11-14 21:49:27 +01:00
Make distiction between terminal and non-terminal applications
This commit is contained in:
parent
b44add70c9
commit
53205d6494
1 changed files with 28 additions and 9 deletions
|
@ -82,20 +82,32 @@ impl Handler {
|
|||
}
|
||||
pub fn open(&self, arg: String) -> Result<()> {
|
||||
let (cmd, args) = self.get_entry()?.get_cmd(Some(arg))?;
|
||||
if self.get_entry()?.term {
|
||||
std::process::Command::new(cmd)
|
||||
.args(args)
|
||||
.status()?;
|
||||
} else {
|
||||
std::process::Command::new(cmd)
|
||||
.args(args)
|
||||
.stdout(std::process::Stdio::null())
|
||||
.spawn()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
pub fn launch(&self, args: Vec<String>) -> Result<()> {
|
||||
let (cmd, mut base_args) = self.get_entry()?.get_cmd(None)?;
|
||||
base_args.extend_from_slice(&args);
|
||||
if self.get_entry()?.term {
|
||||
std::process::Command::new(cmd)
|
||||
.args(base_args)
|
||||
.status()?;
|
||||
} else {
|
||||
std::process::Command::new(cmd)
|
||||
.args(base_args)
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null())
|
||||
.spawn()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +118,7 @@ pub struct DesktopEntry {
|
|||
pub(crate) name: String,
|
||||
pub(crate) exec: String,
|
||||
pub(crate) file_name: String,
|
||||
pub(crate) term: bool,
|
||||
pub(crate) mimes: Vec<Mime>,
|
||||
}
|
||||
|
||||
|
@ -168,6 +181,12 @@ impl TryFrom<PathBuf> for DesktopEntry {
|
|||
mimes.pop();
|
||||
entry.mimes = mimes;
|
||||
}
|
||||
"Terminal" => {
|
||||
entry.term = match inner_rules.next().unwrap().as_str() {
|
||||
"true" => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue