diff --git a/src/main.rs b/src/main.rs index 599c422..d6e95f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,13 @@ Grabs input device through a kernel syscall. This prevents other devices (including kernel-internal ones such as rfkill) from receiving events from the device. +In case of overlap in options provided in command line and evenironment variables, +command line options take precedence. + +# Environment + +DPK_INPUT_DEVICE can be used to provide the path to the input device + # Usage dpk [/PATH/TO/INPUT/DEVICE] @@ -83,13 +90,16 @@ fn run( } /// Open the device on the path provided in the first cli argument -/// or, if none present, allow user to choose one +/// or in DPK_INPUT_DEVICE environment variable +/// or, if neither present, allow user to choose one fn pick_device() -> evdev::Device { let mut args = std::env::args_os(); args.next(); if let Some(dev_file) = args.next() { evdev::Device::open(dev_file).unwrap() + } else if let Ok(dev_file) = std::env::var("DPK_INPUT_DEVICE") { + evdev::Device::open(dev_file).unwrap() } else { let mut devices = evdev::enumerate().collect::>(); devices.reverse();