A modern Vietnamese Input Method Engine (IME) for Linux with direct Unicode input—no pre-edit buffer, no underlines.
Find a file
Khoa Vo 3858aa955c feat: implement Backspace-Replay pattern for perfect engine sync
- Add Engine::replay_keystrokes() — creates fresh engine and replays
  all keystrokes to compute correct screen output from scratch
- Add Daemon::replay_and_inject() — tracks keystroke history and
  screen output, computes diff (backspaces + new text) on each keypress
- Add Daemon::replay_backspace() — pops from history, replays, diffs
- Handle flush chars (space, period, etc.) separately — commit word,
  type char, clear history
- Add FocusIn/FocusOut detection for engine reset on focus loss
- Add CPU pinning (P-cores 0-3) + nice(-10) priority boost
- Clean up 9 dead code warnings (unused fields, constants, types)
- Add replay_keystrokes tests for Telex, VNI, and backspace
- 255 tests pass (was 252)
2026-06-26 08:40:38 +07:00
cli Optimize typing performance and preserve casing on replaced syllables 2026-06-25 19:59:46 +07:00
daemon feat: implement Backspace-Replay pattern for perfect engine sync 2026-06-26 08:40:38 +07:00
engine feat: implement Backspace-Replay pattern for perfect engine sync 2026-06-26 08:40:38 +07:00
packaging X11 capture: proper key tracking, direct clipboard, VNI default 2026-06-26 07:56:52 +07:00
protocol feat: implement Backspace-Replay pattern for perfect engine sync 2026-06-26 08:40:38 +07:00
scripts Fix typing race conditions with unified channel injection, add persistent logging, and align config schemas 2026-06-24 20:30:14 +07:00
ui Optimize typing performance and preserve casing on replaced syllables 2026-06-25 19:59:46 +07:00
.gitignore Gitignore runtime status file 2026-06-24 17:33:39 +07:00
Cargo.toml Viet+ v0.1.0 - Vietnamese Input Method for Linux 2026-06-24 10:13:10 +07:00
LICENSE Viet+ v0.1.0 - Vietnamese Input Method for Linux 2026-06-24 10:13:10 +07:00
Makefile Optimize typing performance and preserve casing on replaced syllables 2026-06-25 19:59:46 +07:00
README.md Update README: add deb packaging, fix make targets, update Quick Start and Installation 2026-06-25 08:33:18 +07:00
vietc.service Viet+ v0.1.1 2026-06-24 17:29:12 +07:00
vietc.toml X11 capture: proper key tracking, direct clipboard, VNI default 2026-06-26 07:56:52 +07:00

Platform Rust License Version


Viet+

Vietnamese Input Method for Linux
Zero underline • Native Wayland/X11 • Built in Rust

About Viet+

Viet+ is a modern Vietnamese input method for Linux that eliminates the underline hell common in other Vietnamese IMEs. Unlike traditional solutions that use pre-edit buffers with ugly underlines and duplicate text, Viet+ implements a Direct Input approach:

  • No pre-edit buffer — keystrokes are instantly converted to Unicode
  • No underline — clean, distraction-free typing
  • No text duplication — just pure Vietnamese
  • Smart modifier overriding — most recently typed shape modifier key takes precedence
  • Tone preservation — tones are preserved perfectly when overriding shape modifiers
  • Both Telex and VNI — support for both Vietnamese input methods

The engine handles complex linguistic rules including:

  • Shape modifier overriding (â↔ă, ô↔ơ, ơ→ô, ă→â)
  • Smart cluster handling (uô+w→ươ, ươ+o→uô)
  • VNI digit modifiers (6/7/8) following the same override logic
  • Flexible end-of-word placement for tones and modifiers
  • Complex consonant handling (ngh, ngh, đ)

The injection layer ensures Vietnamese characters appear correctly by running injection tools (xdotool, wtype, wl-copy, xclip) as the original user, not root, to access the display. This works on both X11 (pkexec) and Wayland (sudo) without requiring password dialogs.

Viet+ is designed for high performance with native setuid/setgid user context switching to avoid slow sudo/PAM overhead, zero telemetry, and full FOSS licensing.

Why Viet+?

Most Vietnamese input methods on Linux suffer from underline hell — pre-edit buffers that duplicate text, show ugly underlines, and break your flow. Viet+ takes a different approach:

Direct Input — keystrokes are instantly converted to Unicode. No pre-edit buffer. No underline. No text duplication. Just pure Vietnamese.


FeaturesQuick StartInput MethodsConfigurationInstallationBuilding


Why Viet+?

Most Vietnamese input methods on Linux suffer from underline hell — pre-edit buffers that duplicate text, show ugly underlines, and break your flow. Viet+ takes a different approach:

Direct Input — keystrokes are instantly converted to Unicode. No pre-edit buffer. No underline. No text duplication. Just pure Vietnamese.


Features

Feature Description
Direct Input Engine No pre-edit buffer, no underline, no text duplication
Telex & VNI Both input methods fully supported
Flexible Diacritic Placement Type modifiers/tone marks at end of syllable (e.g., tranaftrần)
Auto-Restore English Hit space/ESC to undo accidental Vietnamese conversion
ESC Undo Strip all tones from the current word instantly
Smart App Memory Remembers Vietnamese/English per application
Macro Expansion Custom shortcuts (e.g., kokhông)
Unified Injection Unified channel backspace and typing injection to prevent ordering race conditions
Focus Buffer Auto-Reset Automatically clears the engine's compose buffer on focus change between apps
Logging & Rotation Persistent logging at ~/.config/vietc/vietc.log with automatic 10MB rotation
Hot Reload Config changes apply without restart
Casing Preservation Syllable substitutions preserve your exact typing casing (e.g. SaaSả, SAASẢ)
High-Performance Injection Direct native setuid/setgid user context switching to run injection tools instantly with no slow sudo/PAM overhead
Zero Telemetry No keylogging, no network calls, fully FOSS

Quick Start

# Clone and build
git clone https://git.khoavo.myds.me/vndangkhoa/vietc.git
cd vietc
make build-all

# Test the engine interactively
cargo run --bin vietc-cli

# Run the daemon (requires root for keyboard grab + uinput)
sudo make run

# Or download a package from the releases page
#   AppImage: ./Viet+-0.1.0-x86_64.AppImage
#   Debian:   sudo dpkg -i vietc_0.1.0-1_amd64.deb

Input Methods

Telex (Default)

Key Result Example
aa â tantân
aw ă tantăn
ee ê menmên
oo ô to
ow ơ to
ew ê enên
uw ư tu
s á (sắc) asá
f à (huyền) afà
r ả (hỏi) ar
x ã (ngã) axã
j ạ (nặng) aj
dd đ ddđ

VNI

Key Result
a1 á
a2 à
a3
a4 ã
a5
a6 â
a8 ă
e6 ê
o6 ô
o7 ơ
u7 ư

Configuration

Config file: ~/.config/vietc/config.toml or ./vietc.toml

input_method = "telex"
toggle_key = "space"
start_enabled = true
debug = false

[auto_restore]
enabled = true

[app_state]
enabled = true
english_apps = ["code", "vim", "kitty", "foot"]
vietnamese_apps = ["telegram", "discord", "firefox"]

[macros]
ko = "không"
dc = "được"
vs = "với"
lm = "làm"

Architecture

┌──────────────┐     ┌──────────────┐     ┌────────────────┐
│  evdev       │────▶│  Viet+       │────▶│  uinput/X11    │
│  keyboard    │     │  Engine      │     │  injection     │
│  monitor     │     │  (Telex/VNI) │     │                │
└──────────────┘     └──────────────┘     └────────────────┘
                           │
                     ┌─────┴─────┐
                     │  App State │
                     │  Manager   │
                     └───────────┘

Installation

System Dependencies

Component Ubuntu/Debian Fedora Arch
Core daemon (none) (none) (none)
Tray icon libdbus-1-dev pkg-config dbus-devel pkgconf dbus pkgconf

Debian/Ubuntu Package

sudo dpkg -i vietc_0.1.0-1_amd64.deb
# Or build from source:
make deb

The .deb installs the daemon, CLI, tray icon, systemd user service, and config.

AppImage

make appimage
# Requires appimagetool

Run with sudo for keyboard grab:

sudo ./Viet+-0.1.0-x86_64.AppImage

Manual Install

sudo make install
sudo make install-ui  # tray icon (optional)

Building

# Build all backends (uinput + X11 + Wayland)
make build-all

# Run tests (162+ engine tests)
make test

# Run interactive test harness
cargo run --bin vietc-cli

# Build packages
make deb        # .deb package
make appimage   # AppImage

Make Targets

Target Description
make build-all Build all backends (uinput + X11 + Wayland)
make build-ui Build tray icon UI
make test Run all tests
make run Run daemon (debug, requires root)
make deb Build .deb package
make appimage Build AppImage package
make install Install binaries to /usr/local/bin
make install-ui Install tray icon
make clean Clean build artifacts
make fmt Format code
make lint Run clippy

Project Structure

viet+/
├── engine/          # Core IME engine (Telex + VNI)
│   ├── src/
│   │   ├── engine.rs      # Main engine orchestrator
│   │   ├── telex.rs       # Telex state machine
│   │   ├── vni.rs         # VNI engine
│   │   ├── english.rs     # English auto-restore dictionary
│   │   └── tests.rs       # 162+ unit tests
│   └── Cargo.toml
├── protocol/        # Injection backends
│   ├── src/
│   │   ├── inject.rs              # KeyInjector trait
│   │   ├── uinput_monitor.rs      # Universal uinput+ydotool backend
│   │   ├── x11_inject.rs          # X11 XTEST fallback
│   │   └── wayland_im.rs          # Wayland IM context
│   └── Cargo.toml
├── daemon/          # Background daemon
│   ├── src/
│   │   ├── main.rs        # Evdev loop, hot-reload
│   │   ├── config.rs      # TOML config loader
│   │   ├── app_state.rs   # Per-app state manager
│   │   └── display.rs     # Display server detection
│   └── Cargo.toml
├── cli/             # Interactive test harness
├── ui/              # Tray icon application
│   ├── src/
│   │   ├── main.rs        # Tray app entry point
│   │   ├── tray.rs        # System tray icon implementation
│   │   └── config.rs      # UI config reader
│   └── Cargo.toml
├── packaging/       # Distribution packages
│   ├── appimage/    # AppImage build scripts
│   └── deb/         # .deb package build scripts
├── vietc.toml       # Default configuration
├── vietc.service    # Systemd user service
├── Makefile         # Build targets
└── README.md

License

MIT License - see LICENSE for details.


Made with love for the Vietnamese Linux community