summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dunai <a@dun.ai>2023-07-10 18:19:25 +0300
committerGitHub <noreply@github.com>2023-07-10 08:19:25 -0700
commit9c22fcd2ba6ba3d21dd0ab277437d2e472e5e5a5 (patch)
tree307c57f0ac649a41358ae11722816cb50312ed07
parente33ee41cad80421cfa03685d889da94ec65179e4 (diff)
Add option to configure startup delay (#33)
Add option to configure startup delay Co-authored-by: Wez Furlong <wez@wezfurlong.org>
-rw-r--r--evremap.service2
-rw-r--r--src/main.rs8
2 files changed, 7 insertions, 3 deletions
diff --git a/evremap.service b/evremap.service
index d8387a3..67f6e74 100644
--- a/evremap.service
+++ b/evremap.service
@@ -3,7 +3,7 @@ WorkingDirectory=/
# For reasons I don't care to troubleshoot, Fedora 31 won't let me start this
# unless I use `bash -c` around it. Putting the command line in directly
# yields a 203 permission denied error with no logs about what it didn't like.
-ExecStart=bash -c "/usr/bin/evremap remap /etc/evremap.toml"
+ExecStart=bash -c "/usr/bin/evremap remap /etc/evremap.toml -d 0"
Restart=always
[Install]
diff --git a/src/main.rs b/src/main.rs
index 20d6dc6..108ac3b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -31,6 +31,10 @@ enum Opt {
/// Specify the configuration file to be loaded
#[structopt(name = "CONFIG-FILE")]
config_file: PathBuf,
+
+ /// Number of seconds for user to release keys on startup
+ #[structopt(short, long, default_value = "2")]
+ delay: f64,
},
}
@@ -66,14 +70,14 @@ fn main() -> Result<()> {
match opt {
Opt::ListDevices => deviceinfo::list_devices(),
Opt::ListKeys => list_keys(),
- Opt::Remap { config_file } => {
+ Opt::Remap { config_file, delay } => {
let mapping_config = MappingConfig::from_file(&config_file).context(format!(
"loading MappingConfig from {}",
config_file.display()
))?;
log::warn!("Short delay: release any keys now!");
- std::thread::sleep(Duration::new(2, 0));
+ std::thread::sleep(Duration::from_secs_f64(delay));
let device_info = deviceinfo::DeviceInfo::with_name(
&mapping_config.device_name,