Compare commits
3 commits
2f325db170
...
f2cb1defa0
Author | SHA1 | Date | |
---|---|---|---|
f2cb1defa0 | |||
82075e9ff9 | |||
a4e63ae51a |
3 changed files with 26 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
use int_enum::IntEnum;
|
use int_enum::IntEnum;
|
||||||
use log::{error, info, warn};
|
use log::error;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
@ -100,9 +100,6 @@ pub enum KeyMapVariant {
|
||||||
PipeWire {
|
PipeWire {
|
||||||
ids: Vec<String>,
|
ids: Vec<String>,
|
||||||
},
|
},
|
||||||
Key {
|
|
||||||
keycode: u8, //TODO: add real keycodes
|
|
||||||
},
|
|
||||||
Exec {
|
Exec {
|
||||||
command: String,
|
command: String,
|
||||||
args: Option<Vec<String>>,
|
args: Option<Vec<String>>,
|
||||||
|
|
|
@ -4,6 +4,7 @@ use crate::midi_client::KeyEvent;
|
||||||
use crate::mpris_client;
|
use crate::mpris_client;
|
||||||
use crossbeam_channel::Receiver;
|
use crossbeam_channel::Receiver;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
|
use std::process::{Command, Output};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
|
@ -91,8 +92,20 @@ fn eval(key: NanoKeys, state: u8, config: &Arc<Config>) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
KeyMapVariant::PipeWire { ids } => {}
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use log::warn;
|
||||||
use mpris::Player;
|
use mpris::Player;
|
||||||
use mpris::PlayerFinder;
|
use mpris::PlayerFinder;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
@ -36,10 +37,15 @@ where
|
||||||
{
|
{
|
||||||
let player = PlayerFinder::new()
|
let player = PlayerFinder::new()
|
||||||
.expect("Could not connect to D-Bus")
|
.expect("Could not connect to D-Bus")
|
||||||
.find_active()
|
.find_active();
|
||||||
.expect("Could not find any player");
|
match player {
|
||||||
|
Ok(p) => {
|
||||||
function(&player);
|
function(&p);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!("Could not find an active player: {err}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn exec_functionality<F>(player_id: Option<&str>, exec_closure: F)
|
fn exec_functionality<F>(player_id: Option<&str>, exec_closure: F)
|
||||||
|
|
Loading…
Reference in a new issue