Add external command execution

This commit is contained in:
GHOSCHT 2024-03-14 11:20:47 +01:00
parent a4e63ae51a
commit 82075e9ff9
Signed by: ghoscht
GPG key ID: 2C2C1C62A5388E82

View file

@ -4,6 +4,7 @@ use crate::midi_client::KeyEvent;
use crate::mpris_client;
use crossbeam_channel::Receiver;
use log::{error, info, warn};
use std::process::{Command, Output};
use std::sync::Arc;
use std::thread;
@ -92,7 +93,20 @@ fn eval(key: NanoKeys, state: u8, config: &Arc<Config>) {
},
KeyMapVariant::PipeWire { ids } => {}
KeyMapVariant::Key { keycode } => {}
KeyMapVariant::Exec { command, args } => {}
KeyMapVariant::Exec { command, args } => {
let output: Result<Output, std::io::Error> = match args {
Some(some_args) => Command::new(command).args(some_args).output(),
None => Command::new(command).output(),
};
match output {
Ok(out) => {
info!("{:?}", out);
}
Err(err) => {
error!("{:?}", err);
}
}
}
}
}
}