From 82075e9ff9a1da31f4b4dce91b6538321357a5a0 Mon Sep 17 00:00:00 2001 From: GHOSCHT <31184695+GHOSCHT@users.noreply.github.com> Date: Thu, 14 Mar 2024 11:20:47 +0100 Subject: [PATCH] Add external command execution --- src/controller.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/controller.rs b/src/controller.rs index 6399733..fee658a 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -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) { }, KeyMapVariant::PipeWire { ids } => {} KeyMapVariant::Key { keycode } => {} - KeyMapVariant::Exec { command, args } => {} + KeyMapVariant::Exec { command, args } => { + let output: Result = 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); + } + } + } } } }