tonhowtf/omniget · error
digitar
Error message
digitar: {} What it means
Wrapper error in type_text: an enigo text-typing step failed — commonly because the OS denied synthetic keyboard input (missing Accessibility permission on macOS) or the keyboard device could not be opened on this session.
Solutions
- Retry the typing once — transient backend failures often resolve on a second attempt.
- Fall back to press_paste() (clipboard + Cmd/Ctrl+V), which avoids per-character synthesis.
- Check that macOS Accessibility permission is still granted and the target window accepts synthetic input.
- Sanitize or strip unsupported characters from the text before typing.
Example fix
// before
enigo.text(text).map_err(|e| anyhow!("digitar: {}", e))?;
// after
if let Err(e) = enigo.text(text) {
clipboard::set_text(text)?;
press_paste()?; // fallback path
} Defensive patterns
Strategy: fallback
Try / catch
// fall back to clipboard paste when typing fails
if let Err(e) = dictation::type_text(text) {
clipboard::set_text(text)?;
dictation::press_paste()?;
} Prevention
- Implement clipboard+paste as a built-in retry path for typing failures.
- Strip characters not producible by the target keyboard layout.
- Keep a short delay after hotkey release (the library already sleeps 150ms — keep it).
When it happens
Trigger: enigo.text() returns Err when synthesizing keystrokes for the given string — unsupported characters/layout issues or the injection backend failing at runtime after successful construction.
Common situations: Text contains characters the platform layout cannot produce; keyboard focus moved to a secure/privileged window that swallows synthetic input; macOS permission revoked mid-session; Wayland compositor rejects synthetic key events.
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/7372de49dea92470.
Report an issue: GitHub.
Appendix: source
Thrown at src-tauri/omniget-core/src/core/tools/dictation.rs:367
Some(e.to_string()),
);
Err(e)
}
}
}
pub fn is_recording() -> bool {
REC.lock().unwrap_or_else(|e| e.into_inner()).is_some()
}
/// Digita o texto onde o cursor estiver.
pub fn type_text(text: &str) -> anyhow::Result<()> {
use enigo::{Enigo, Keyboard, Settings};
let mut enigo = Enigo::new(&Settings::default())
.map_err(|e| anyhow!("teclado: {} (macOS: permissao de Acessibilidade)", e))?;
// 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)View on GitHub (pinned to 8600b91f42)