diff options
author | Dominik MiedziĆski <dominik@mdzn.pl> | 2017-05-25 18:19:00 +0200 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-05-25 09:19:00 -0700 |
commit | 5977776874d16febbf26d73e833b4e4d104aa359 (patch) | |
tree | 7c8c2db296e28d33a39a924dbf4fe263e71b6e8f /src/input.rs | |
parent | 112abf385fef32f30618b4ebb1d1c651661a6fae (diff) | |
download | alacritty-5977776874d16febbf26d73e833b4e4d104aa359.tar.gz alacritty-5977776874d16febbf26d73e833b4e4d104aa359.zip |
Add support for running commands on key press (#566)
Based on option `command` in key binding section in config, e.g.
- { key: N, mods: Control|Shift, command: alacritty }
# or
- {
key: N,
mods: Control|Shift,
command: {
program: "alacritty",
args: ["-e", "vttest"],
}}
specified command will be run in the background on key press. Alacritty
doesn't wait for its result nor block IO.
Diffstat (limited to 'src/input.rs')
-rw-r--r-- | src/input.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs index a1bd5c9a..47374e47 100644 --- a/src/input.rs +++ b/src/input.rs @@ -20,6 +20,7 @@ //! determine what to do when a non-modifier key is pressed. use std::borrow::Cow; use std::mem; +use std::process::Command; use std::time::Instant; use copypasta::{Clipboard, Load, Buffer}; @@ -144,6 +145,9 @@ pub enum Action { /// Paste contents of selection buffer PasteSelection, + /// Run given command + Command(String, Vec<String>), + /// Quits Alacritty. Quit, } @@ -174,6 +178,17 @@ impl Action { warn!("Error loading data from clipboard. {}", Red(err)); }); }, + Action::Command(ref program, ref args) => { + trace!("running command: {} {:?}", program, args); + match Command::new(program).args(args).spawn() { + Ok(child) => { + debug!("spawned new proc with pid: {}", child.id()); + }, + Err(err) => { + warn!("couldn't run command: {}", err); + }, + } + }, Action::Quit => { // FIXME should do a more graceful shutdown ::std::process::exit(0); |