tonhowtf/omniget · error
{}
Error message
{} What it means
press_paste() wraps the enigo.key(modifier, Direction::Press) failure with the raw error via anyhow!("{}", e). The Enigo backend failed to press the modifier key (Cmd on macOS, Ctrl elsewhere) needed for the paste shortcut.
Solutions
- Retry press_paste() once — the failure is often transient.
- Verify keyboard permissions are still granted (macOS Accessibility).
- Ensure the app runs in an active graphical session (not locked/backgrounded).
- If persistent on Linux/Wayland, switch to X11 or a different input backend.
Example fix
null
Defensive patterns
Strategy: retry
Try / catch
// retry the whole paste sequence once on failure
if dictation::press_paste().is_err() {
std::thread::sleep(std::time::Duration::from_millis(200));
dictation::press_paste()?;
} Prevention
- Retry transient injection failures with a small backoff.
- Avoid calling paste while the target window is locked or secure-input is active.
- Detect and recover from stuck modifier keys by sending a Release before retrying.
When it happens
Trigger: enigo.key(Key::Meta or Key::Control, Direction::Press) returns Err after Enigo was constructed successfully.
Common situations: Platform backend loses access to the input device mid-session (display sleep, session switch); Wayland rejects synthetic input; intermittent enigo driver failure.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12).
Data as JSON: /api/errors/67349ac347753205.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/dictation.rs:383
// Um instante para o usuário soltar o atalho antes de digitar.
std::thread::sleep(std::time::Duration::from_millis(150));
enigo.text(text).map_err(|e| anyhow!("digitar: {}", e))?;
Ok(())
}
/// Cmd+V / Ctrl+V (o app coloca o texto na área de transferência antes).
pub fn press_paste() -> anyhow::Result<()> {
use enigo::{Direction, Enigo, Key, Keyboard, Settings};
let mut enigo = Enigo::new(&Settings::default()).map_err(|e| anyhow!("teclado: {}", e))?;
std::thread::sleep(std::time::Duration::from_millis(150));
let modifier = if cfg!(target_os = "macos") {
Key::Meta
} else {
Key::Control
};
enigo
.key(modifier, Direction::Press)
.map_err(|e| anyhow!("{}", e))?;
enigo
.key(Key::Unicode('v'), Direction::Click)
.map_err(|e| anyhow!("{}", e))?;
enigo
.key(modifier, Direction::Release)
.map_err(|e| anyhow!("{}", e))?;
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn defaults() {
let o = options();
assert_eq!(o.model, "base");
assert_eq!(o.output, "type");View on GitHub (pinned to 8600b91f42)