mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
While dictating mute or media pause started at the shortcut press, so chords and short taps muted the output. The audio loop now requests it when the capture becomes intentional at 300 ms, and never during a release tail.
319 lines
17 KiB
Markdown
319 lines
17 KiB
Markdown
# Install The Linux Beta
|
|
|
|
The Linux beta targets x86_64 Linux: i3/X11 and compatible wlroots-based Wayland
|
|
compositors such as Hyprland or Sway. Audio uses ALSA, including PipeWire systems
|
|
with ALSA compatibility. Inference uses Vulkan when available and can fall back
|
|
to the CPU. The GPUI Settings window still needs a Vulkan driver, even with CPU
|
|
inference; `vulkan-icd-loader` alone is not a driver. Install a driver for your GPU
|
|
or a software Vulkan driver. See the Wayland requirements below.
|
|
|
|
Linux opens the same window as macOS and Windows: Settings, Modes, Voice Action,
|
|
and History. Voice commands, website mode rules, and meetings are macOS-only.
|
|
This is not universal Wayland support: GNOME and KDE are not covered by the
|
|
current clipboard, virtual-keyboard, and overlay protocol contract. Shortcuts
|
|
are general: the desktop's GlobalShortcuts portal when it has one, otherwise
|
|
your desktop's own keybindings running `hex` commands (see
|
|
[Shortcuts](#shortcuts)).
|
|
|
|
For Nix/NixOS, use the [Nix guide](nix.md). Nix owns updates to that installation;
|
|
HEX's signed updater owns only the direct-install layout below.
|
|
|
|
## Background Service And Settings
|
|
|
|
The dictation runtime is a **per-user systemd service**, `hex.service`, not a
|
|
system-wide/root daemon. It owns the microphone, hotkeys, model downloads and
|
|
workers, sounds, paste, and History recording. Settings is a separate client:
|
|
it saves `settings.json` and asks the service to reload it, records shortcuts
|
|
for the service to register, asks it to prepare models, and reads History from
|
|
the same file.
|
|
Closing Settings stops neither dictation nor a model download. There is no
|
|
Linux tray icon.
|
|
|
|
Settings live in `settings.json` in HEX's data directory, the same file macOS
|
|
and Windows use. On first launch, an existing `linux-settings.json` is
|
|
migrated once and kept as `linux-settings.json.migrated`.
|
|
|
|
```sh
|
|
hex start # start the service and listen; no window
|
|
hex app # open Settings; connect to/start the service
|
|
hex status # query live service state, not an old log entry
|
|
hex stop # stop the service and release microphone/hotkeys
|
|
hex restart # restart using this desktop's environment
|
|
# (over SSH: the one it last ran in)
|
|
journalctl --user -u hex.service # service diagnostics
|
|
```
|
|
|
|
Settings also offers Start/Stop for the listener without stopping the service.
|
|
An existing paused listener stays paused when Settings opens. A crashed client
|
|
does not stop dictation. A disconnected client loses its uncommitted shortcut
|
|
capture; the old binding and prior listening state are restored. The client
|
|
reconnects after a service restart and never replays uncertain mutation requests.
|
|
|
|
The direct installer creates the user unit and an XDG autostart entry that runs
|
|
`hex start`. The launcher writes an owner-only `session.env` containing only
|
|
display/session variables before starting systemd; missing variables explicitly
|
|
clear stale Wayland/X11 values inherited by the user manager. No permissions are
|
|
granted. The service is `PartOf=graphical-session.target`; desktops managing a
|
|
custom session target must bind its lifetime to their login/logout lifecycle.
|
|
Restart-on-failure belongs to systemd, not the Settings process.
|
|
There is one active desktop service per user: `hex start` hands it over with a
|
|
restart if the display/session changed. Opening Settings alone never silently
|
|
moves an existing runtime from another desktop.
|
|
|
|
IPC uses an owner-only Unix socket in HEX's data directory, same-user peer
|
|
credentials, versioned bounded frames, bounded queues, and I/O deadlines. It is
|
|
not a network API or the macOS embedded transcription SDK service.
|
|
|
|
For development or a non-systemd supervisor, run `cargo run -- service` in the
|
|
foreground, then `cargo run -- app` separately. `hex dictate` remains an explicit
|
|
foreground diagnostic listener and cannot coexist with the service's listener.
|
|
With `HEX_APPLICATION_SUPPORT_DIR` set, clients only connect to an explicitly
|
|
started service at that data root; they never start/restart the installed user
|
|
unit. `hex stop` then shuts down only that custom service through its socket.
|
|
Legacy `hex app --hidden` now means `hex start`; it never creates a hidden UI.
|
|
`hex status --lines 40` retains the explicit diagnostic-log view.
|
|
|
|
## Install A Published Build
|
|
|
|
The published build targets current x86_64 Arch Linux and needs glibc 2.44 or
|
|
later. Install it with:
|
|
|
|
```sh
|
|
curl -fsSL https://downloads.hex.kitlangton.com/install-linux.sh | sh
|
|
```
|
|
|
|
If a runtime library is missing, the installer names the Arch packages to
|
|
install. Then open Hex from your application launcher, or run
|
|
`~/.local/bin/hex app`; its first run downloads a speech model.
|
|
|
|
To install the dependencies up front, or to inspect the installer before
|
|
running it:
|
|
|
|
```sh
|
|
sudo pacman -S --needed alsa-lib curl gtk3 gtk-layer-shell jq libappindicator-gtk3 \
|
|
libxkbcommon libxkbcommon-x11 libx11 libxcb openblas openssl util-linux \
|
|
vulkan-icd-loader wl-clipboard wtype xxd
|
|
curl --proto '=https' --tlsv1.2 -fsSLO \
|
|
https://downloads.hex.kitlangton.com/install-linux.sh
|
|
less install-linux.sh
|
|
sh install-linux.sh
|
|
~/.local/bin/hex model install
|
|
~/.local/bin/hex app
|
|
```
|
|
|
|
The installer verifies the signed release feed, exact artifact size, and
|
|
SHA-256 before installing. It uses no root access. It creates the managed
|
|
version layout, `~/.local/bin/hex`, a desktop launcher, and an XDG autostart
|
|
entry and a `hex.service` user unit. It does not start recording during installation.
|
|
|
|
Remove the application while preserving logs and settings with:
|
|
|
|
```sh
|
|
sh install-linux.sh uninstall
|
|
```
|
|
|
|
## Install From Source
|
|
|
|
Install the native dependencies and, for a source build, the Rust toolchain:
|
|
|
|
```sh
|
|
sudo pacman -S --needed base-devel git rustup python alsa-lib curl jq openssl xxd \
|
|
util-linux gtk3 gtk-layer-shell libappindicator-gtk3 libxkbcommon \
|
|
libxkbcommon-x11 libx11 libxcb openblas vulkan-headers vulkan-icd-loader \
|
|
shaderc spirv-headers clang cmake pkgconf wl-clipboard wtype
|
|
rustup default stable
|
|
```
|
|
|
|
Build and install HEX as your desktop user:
|
|
|
|
```sh
|
|
git clone https://github.com/anomalyco/hex.git
|
|
cd hex
|
|
./scripts/install-linux.sh
|
|
~/.local/bin/hex model install
|
|
~/.local/bin/hex app
|
|
```
|
|
|
|
Do not run the installer as root. It installs a user-local binary, desktop
|
|
launcher, and autostart entry in the same managed layout as published builds.
|
|
Newer signed releases can therefore replace this installed source build through
|
|
the in-app updater. `cargo run --release -- app` runs an unmanaged development
|
|
binary instead.
|
|
|
|
## Dictate
|
|
|
|
Hold **Alt-Space**, speak, then release. Double-tap the shortcut to keep
|
|
recording, press the same chord again to finish, or press Escape to cancel the
|
|
active recording. **Double-tap only** waits for two complete taps before
|
|
recording, and **Toggle** mode starts and stops with single presses.
|
|
**Ctrl-Alt-V** pastes the last dictation again. Settings shows listener state,
|
|
Start/Stop, and operational errors. Changing a shortcut or a setting the
|
|
listener reads at start temporarily stops listening and restores the previous
|
|
running state after the edit.
|
|
|
|
Modes apply corrections, OpenCode rewriting, and transformations per
|
|
application. On X11, HEX reads the frontmost application from the active
|
|
window's process name (`code`, `firefox`); the application picker lists
|
|
`.desktop` entries with their icons. Wayland doesn't report the focused window,
|
|
so the Global mode applies there. Completed dictations are kept in History.
|
|
|
|
Voice Action, once enabled, records an instruction while you hold
|
|
**Ctrl-Alt-I**, pairs it with the primary selection (the text you selected), asks
|
|
OpenCode, and pastes the reply.
|
|
|
|
**Microphone mode** can release the microphone between dictations; it then opens
|
|
on the shortcut press without pre-roll. **While dictating** can mute the default
|
|
output through `wpctl` (PipeWire) or `pactl` (PulseAudio), or pause playing
|
|
MPRIS media players over D-Bus, once the hold passes 300 ms, so shortcut chords
|
|
and short taps never do; HEX restores only what it changed.
|
|
Cancelling shortcut capture preserves the old binding unless the new binding
|
|
has already been saved; listening resumes only if it was previously running.
|
|
|
|
## Shortcuts
|
|
|
|
Hex gets its shortcuts one of three ways, and all of them drive the same
|
|
dictation rules:
|
|
|
|
- **X11:** Hex grabs the shortcuts Settings records.
|
|
- **Wayland with the GlobalShortcuts portal** (for example niri with
|
|
`xdg-desktop-portal-gnome`, GNOME, or KDE): Hex asks the desktop for the
|
|
shortcuts Settings records. The desktop decides: it may grant them, assign
|
|
another key, or refuse one that it or another binding already uses. Settings
|
|
lists what the desktop granted under **Desktop shortcuts**, with an error for
|
|
any it refused. The portal identifies Hex by its installed `hex.desktop`
|
|
entry and by inspecting the service process, so run `hex service` directly:
|
|
a setgid wrapper such as `newgrp`, once used to grant input-device access,
|
|
makes the portal refuse Hex. The desktop delivers the keys to Hex, not to the
|
|
focused application.
|
|
- **Wayland without the portal** (for example Sway): nothing registers global
|
|
shortcuts. Settings lists these commands; bind them in your desktop's own
|
|
keyboard configuration:
|
|
|
|
```sh
|
|
hex dictation start # bind to a key's press: start recording
|
|
hex dictation stop # bind to the same key's release: stop and transcribe
|
|
hex dictation toggle # one key: start, then stop and transcribe
|
|
hex dictation cancel # discard the recording
|
|
hex paste-last # paste the last dictation again
|
|
hex voice-action start # Voice Action, when enabled: press
|
|
hex voice-action stop # and release
|
|
hex voice-action toggle
|
|
```
|
|
|
|
For example, hold-to-dictate on F9 in Sway, and a toggle in any desktop that
|
|
runs commands on key presses only:
|
|
|
|
```sh
|
|
bindsym F9 exec hex dictation start
|
|
bindsym --release F9 exec hex dictation stop
|
|
bindsym Ctrl+Alt+d exec hex dictation toggle
|
|
```
|
|
|
|
The commands are safe to bind anywhere, including X11 beside the grabs. They
|
|
talk to the running service and never start it: without one, or while Hex is
|
|
not listening, they print a one-line error and exit non-zero. Starting while recording,
|
|
stopping while idle, and cancelling while idle do nothing, so key repeat is
|
|
harmless. Start and stop bypass Hold, Toggle, and double-tap: start records,
|
|
stop finishes. A shortcut press also finishes a recording a command started.
|
|
|
|
Escape cancels only while something records. On Wayland with the portal, Hex
|
|
binds Escape, and Escape with the recording shortcut's modifiers, only for the
|
|
length of the recording; the desktop then keeps that Escape from the focused
|
|
application. Without the portal, bind `hex dictation cancel` instead.
|
|
|
|
Shortcuts need a non-modifier key. Modifier-only shortcuts, such as Super
|
|
alone, are not supported on Linux.
|
|
|
|
On X11, HEX first grabs Escape with any modifiers. If another application owns
|
|
a modified Escape shortcut, HEX falls back to plain Escape with Caps/Num Lock
|
|
variants; release other modifiers before cancelling. If plain Escape also
|
|
conflicts, dictation continues and Settings and `hex status` show
|
|
`Escape cancel unavailable: another application holds Escape`. Finish with the
|
|
dictation shortcut instead. HEX logs once per conflict episode and retries on
|
|
the next capture; a successful grab clears the warning.
|
|
|
|
Recording sounds are enabled at 50% volume by default, including when upgrading
|
|
older settings. A start sound is queued immediately when the shortcut starts capture,
|
|
a stop sound marks the end of a retained recording (not completed transcription
|
|
or paste), and a cancel sound acknowledges cancellation of an active capture.
|
|
Brief taps still play the start sound, but recordings shorter than 300 ms remain
|
|
discarded and do not play the stop sound. **Sound volume** in Settings
|
|
offers Off, 25%, 50%, 75%, and 100%; changes save immediately without restarting
|
|
the listener and preview the start sound unless set to Off. `hex dictate` uses
|
|
the same saved volume. Playback uses the default audio output through a bounded
|
|
background worker; unavailable audio output does not prevent dictation.
|
|
|
|
Closing Settings leaves the service running on both X11 and Wayland. The
|
|
service-owned recording/processing pill never takes focus or intercepts clicks,
|
|
even with Settings closed: a layer-shell surface on Wayland, an override-redirect
|
|
popup on X11. **Recording indicator** places it at the top or bottom of the
|
|
screen, or turns it off.
|
|
|
|
Insertion uses the clipboard and **Ctrl-V** for new installations. Enable
|
|
**Terminal paste shortcut** in Settings for targets that require **Ctrl-Shift-V**.
|
|
Existing X11 settings retain their previous Ctrl-Shift-V behavior until changed.
|
|
The target application must accept the selected binding. The beta leaves the
|
|
transcript on the clipboard; arbitrary previous
|
|
clipboard formats are not restored. A short settling delay prevents immediate
|
|
back-to-back replacement, but is not an acknowledgment from a stalled target
|
|
application (see [#24](https://github.com/anomalyco/hex/issues/24)).
|
|
|
|
## Native Wayland Requirements
|
|
|
|
- Export the compositor's nonempty `WAYLAND_DISPLAY` in the launch environment.
|
|
HEX, GTK, and GPUI select the same native backend even when XWayland's
|
|
`DISPLAY` is also present. `XDG_SESSION_TYPE` alone does not select Wayland.
|
|
- Install `wl-clipboard` and `wtype`. The compositor must support their clipboard
|
|
and virtual-keyboard protocols. There is no silent XWayland, direct-typing, or
|
|
privileged input-injection fallback. Transcript text travels on stdin, not
|
|
command-line arguments.
|
|
- The overlay requires layer-shell. Settings reports when the HUD is unavailable
|
|
rather than presenting a normal focus-taking window as an overlay.
|
|
- Shortcuts come from the GlobalShortcuts portal or from your own keybindings
|
|
for the `hex` commands ([Shortcuts](#shortcuts)). HEX reads no input devices
|
|
and needs no `input` group membership or other device permission. If the
|
|
desktop closes the portal session, the listener stops with an error and an
|
|
active recording is cancelled; enable it again from Settings or `hex start`.
|
|
- Paste does not wait for held keys: `wtype`'s virtual keyboard sends its own
|
|
modifiers, so Ctrl+V stays Ctrl+V while you still hold a shortcut.
|
|
|
|
## Updates And Validation
|
|
|
|
Managed installs check for signed updates when the service starts and every
|
|
24 hours until an update is ready. HEX downloads, verifies, and activates an
|
|
available update, then offers a **Restart** button in Settings for the service. The next launch
|
|
through `~/.local/bin/hex` also uses the activated version. The signed update
|
|
path is implemented but still awaiting a complete cross-version validation on
|
|
the supported Arch/i3 host.
|
|
|
|
See [`plans/linux.md`](plans/linux.md) for the engineering contract and remaining
|
|
validation work. The native Wayland implementation builds on the feature
|
|
proposed in [PR #28](https://github.com/anomalyco/hex/pull/28), with separate
|
|
input-state, lifecycle, and paste regression coverage. Physical device,
|
|
compositor, and target-application smoke tests remain necessary before a release.
|
|
`scripts/test-wayland-paste.sh /path/to/compiled-test-executable /path/to/voice-control` runs the real
|
|
paste helpers against a GTK target under an isolated headless Sway compositor.
|
|
Its first paste runs while another virtual keyboard holds Ctrl and Alt.
|
|
It also launches an isolated service and Settings client, repeats paste while
|
|
Settings remains open, and verifies that closing Settings leaves the service
|
|
reachable. It requires the GTK development
|
|
libraries, Sway, `wl-clipboard`, `wtype`, `dbus-run-session`, and a Vulkan driver
|
|
(Mesa's software driver is sufficient), and must run as a non-root user. It uses
|
|
isolated app data and no microphone; CI runs it with the display-free suite and
|
|
Xvfb hotkey tests.
|
|
|
|
`scripts/test-linux-dictation.sh /path/to/voice-control /path/to/parakeet-unified-en-0.6b-Q8_0.gguf /path/to/jfk.wav`
|
|
checks the complete X11 app dictation path with a private PulseAudio virtual
|
|
microphone and Xvfb display. It opens and closes Settings while leaving the service
|
|
running, replays the public JFK sample from whisper.cpp, holds and releases the real
|
|
shortcut, verifies the transcribed words in a GTK editor, and checks orderly
|
|
application shutdown and microphone release. It needs PulseAudio, its ALSA
|
|
plugin, `xdotool`, Xvfb, the GTK development libraries, and a Vulkan driver for
|
|
Settings (Mesa's software driver is sufficient). It runs as a normal user with
|
|
temporary settings; it does not use physical audio devices or personal recordings.
|
|
CI downloads and verifies the pinned model and sample for this check.
|
|
|
|
`python3 scripts/test-linux-service.py /path/to/voice-control` is a display-free,
|
|
device-free IPC/lifecycle check: same-user socket permissions, sole service
|
|
ownership, client disconnects, shortcut-edit cleanup, invalid/oversized/stalled
|
|
frames, persisted volume, crash/stale-socket recovery, and orderly shutdown.
|