tonhowtf/omniget · error

teclado: (macOS: permissao de Acessibilidade)

Error message

teclado: {} (macOS: permissao de Acessibilidade)

What it means

type_text() wraps Enigo::new(&Settings::default()) failure with 'teclado: {} (macOS: permissao de Acessibilidade)'. Enigo cannot initialize its keyboard backend — most often the process lacks Accessibility permission on macOS.

Solutions

  1. macOS: add the app (or terminal) to System Settings > Privacy & Security > Accessibility and restart it.
  2. Linux: ensure a display session exists and the user has permission for the input backend (add to 'input' group for uinput, or run under X11).
  3. Use press_paste() + clipboard as an alternative typing path if keyboard synthesis remains unavailable.
  4. Update the enigo dependency if the backend constructor fails on a supported platform (library bug).

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

// macOS (Tauri/objc): check accessibility permission before typing
// AXIsProcessTrusted() == true means Accessibility granted

Try / catch

match dictation::type_text(text) {
    Err(e) if e.to_string().contains("teclado:") => prompt_accessibility_permission(),
    other => other?,
}

Prevention

When it happens

Trigger: Enigo::new() returns Err during type_text(), i.e. the synthetic keyboard backend fails to construct.

Common situations: macOS: app not granted Accessibility (System Settings > Privacy & Security > Accessibility); Linux: missing X11/Wayland/uinput access (no XDG_SESSION or not in input group); running in a sandboxed/bare environment with no display server.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/fb512d049e41a8e4. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/dictation.rs:364

                "error",
                0,
                None,
                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)

View on GitHub (pinned to 8600b91f42)