GRAB_DEVICE can be omitted and defaults to true

This commit is contained in:
cyber-sushi 2024-04-18 18:51:53 +02:00
parent b52349e681
commit ed8a93ecbd
2 changed files with 9 additions and 10 deletions

View file

@ -26,6 +26,7 @@ pub struct RawConfig {
pub remap: HashMap<String, Vec<Key>>, pub remap: HashMap<String, Vec<Key>>,
#[serde(default)] #[serde(default)]
pub commands: HashMap<String, Vec<String>>, pub commands: HashMap<String, Vec<String>>,
#[serde(default)]
pub settings: HashMap<String, String>, pub settings: HashMap<String, String>,
} }

View file

@ -112,15 +112,14 @@ pub async fn start_reader(reader: EventReader) {
pub fn get_event_stream(path: &Path, config: HashMap<String, Config>) -> EventStream { pub fn get_event_stream(path: &Path, config: HashMap<String, Config>) -> EventStream {
let mut device: Device = Device::open(path).expect("Couldn't open device path."); let mut device: Device = Device::open(path).expect("Couldn't open device path.");
if config.get("default") match config.get("default").unwrap().settings.get("GRAB_DEVICE") {
.unwrap() Some(value) => {
.settings if value == &true.to_string() {
.get("GRAB_DEVICE") device.grab().unwrap()
.expect("No GRAB_DEVICE setting specified, this device will be ignored.") == &"true".to_string() }
{ }
device.grab().unwrap(); None => device.grab().unwrap()
}; }
let stream: EventStream = device.into_event_stream().unwrap(); let stream: EventStream = device.into_event_stream().unwrap();
return stream return stream
} }
@ -143,4 +142,3 @@ pub fn is_mapped(udev_device: &tokio_udev::Device, config_files: &Vec<Config>) -
return false return false
} }