Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/screenshots/tactus/letters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/tactus/setup-keyboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/screenshots/tactus/theme-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
674 changes: 674 additions & 0 deletions packages/tactus/COPYING

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions packages/tactus/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# SPDX-License-Identifier: 0BSD
#
# Tactus, an on-screen keyboard that corrects words as they are typed.
# Opt-in: nothing depends on it, and squeekboard stays the phone's keyboard
# until the owner picks Tactus (Setup > Keyboard, or `omamobile-osk use
# tactus`, from an omamobile-shell that has omamobile-osk).
#
# Built from Stevia 0.59.0 (https://gitlab.gnome.org/World/Phosh/stevia,
# GPL-3.0-or-later), whose Wayland side, layout files and emoji data it keeps:
# - patches/0001 to 0006, each with what it does and why in its header;
# - source/ and tools/: Tactus's own sources (the typing engine, the
# autocorrection, the drawing) and the checks that run with no window.
# The word counts the autocorrection weighs are hermitdave's FrequencyWords
# (content/2018/en/en_50k.txt, made from OpenSubtitles 2018, CC-BY-SA-4.0),
# fetched at a pinned commit and installed unchanged.
#
# Everything is under /usr/lib/tactus with its own name and its own settings
# schemas, so it sits beside squeekboard: Arch's stevia package conflicts with
# squeekboard (both ship mobi.phosh.OSK.service), which omamobile-shell needs.
# - -Ddefault_osk=false and the unit directory inside the prefix: neither
# the desktop file nor the unit is wanted (the package removes both), and
# the unit would otherwise land on squeekboard's file.
# - The binary is renamed to tactus: Hyprland names a virtual keyboard after
# its binary, and omamobile-shell's key binds go by that name
# (hl-virtual-keyboard-tactus).

pkgname=tactus
pkgver=$(cat "${startdir:-.}/version")
pkgrel=1
_stevia=0.59.0
_counts=34bb6447a96d4434dc2d4b24e0cf946c523090b3
pkgdesc='An on-screen keyboard that corrects words as they are typed (opt-in; Omarchy Mobile)'
arch=(aarch64)
url='https://github.com/derekross/omarchy-mobile'
license=(GPL-3.0-or-later CC-BY-SA-4.0) # CC-BY-SA: the word counts
depends=(cairo dconf feedbackd glib2 glibc gnome-desktop gsettings-desktop-schemas
gst-plugins-base-libs gstreamer gtk3 hunspell json-glib libgmobile libhandy
libsoup3 libxkbcommon pango systemd-libs wayland
hunspell-en_us # the dictionary the autocorrection asks
noto-fonts-emoji) # the emoji page
makedepends=(meson ninja glib2-devel wayland-protocols pkgconf)
checkdepends=(xorg-server-xvfb adwaita-fonts) # the widget's checks draw off screen
source=("stevia-v$_stevia.tar.gz::https://gitlab.gnome.org/World/Phosh/stevia/-/archive/v$_stevia/stevia-v$_stevia.tar.gz"
"en_50k-$_counts.txt::https://raw.githubusercontent.com/hermitdave/FrequencyWords/$_counts/content/2018/en/en_50k.txt")
sha256sums=('bc2343929fd5f1b5206581aeef2293acba537b5ed5489a94634d689ada4cd397'
'5351ff405b1126ef555791dd4d9798a48e3e9a501a9fc481a9da957752cfb458')

prepare() {
cd "stevia-v$_stevia"
local p
for p in "$startdir"/patches/*.patch; do
patch -Np1 -F0 -i "$p"
done
cp "$startdir"/source/tactus-*.[ch] src/
cp "$startdir"/tools/tactus-*-test.c tools/
}

build() {
meson setup build "stevia-v$_stevia" --prefix=/usr/lib/tactus --buildtype=plain \
--wrap-mode=nodownload -Db_pie=true \
-Dtests=false -Dman=false -Dgtk_doc=false -Duim=disabled -Dgovarnam=disabled \
-Ddefault_osk=false -Dsystemd_user_unit_dir=/usr/lib/tactus/lib/systemd/user
meson compile -C build
}

check() {
TACTUS_WORD_COUNTS="$srcdir/en_50k-$_counts.txt" "$startdir/test/all" --built "$srcdir/build" "$srcdir/stevia-v$_stevia"
}

package() {
meson install -C build --destdir "$pkgdir"
local p="$pkgdir/usr/lib/tactus"
mv "$p/bin/phosh-osk-stevia" "$p/bin/tactus"
# Not started by a unit or a desktop file: omamobile-osk runs /usr/bin/tactus
rm -rf "$p/lib/systemd" "$p/share/applications" "$p/share/metainfo"
rmdir --ignore-fail-on-non-empty "$p/lib"
# Tactus's defaults for Stevia's settings: its own completion off
install -Dm644 "$startdir/tactus.gschema.override" "$p/share/glib-2.0/schemas/10_tactus.gschema.override"
glib-compile-schemas --strict "$p/share/glib-2.0/schemas"
install -Dm644 "en_50k-$_counts.txt" "$p/share/phosh-osk-stevia/en_50k.txt"
install -Dm755 "$startdir/tactus" "$pkgdir/usr/bin/tactus"
install -Dm644 "stevia-v$_stevia/COPYING" "$pkgdir/usr/share/licenses/$pkgname/COPYING"
install -Dm644 "$startdir/WORD-COUNTS" "$pkgdir/usr/share/licenses/$pkgname/WORD-COUNTS"
}
90 changes: 90 additions & 0 deletions packages/tactus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!-- SPDX-License-Identifier: GPL-3.0-or-later -->
# tactus

Tactus is an on-screen keyboard an owner may choose instead of squeekboard. It corrects words as they are typed, the way the keyboards on current phones do. Opt-in: no image installs it, nothing depends on it, and squeekboard stays the phone's keyboard until the owner picks Tactus.

<p align="center">
<img src="../../docs/screenshots/tactus/letters.png" width="45%" alt="Tactus in Omarchy's Tokyo Night theme">
</p>

It is built from [Stevia](https://gitlab.gnome.org/World/Phosh/stevia) 0.59.0 (GPL-3.0-or-later), whose Wayland side, layout files and emoji data it keeps. The keys, the emoji page and everything about what gets typed are written anew: six patches to Stevia's files in `patches/`, each with what it does and why in its header, and Tactus's own sources in `source/` (the typing engine, the autocorrection, the drawing) and `tools/` (its checks).

## Choosing it

Install the package, then Setup > Keyboard in Omarchy's menu (the gear in quick settings): Standard is squeekboard, Tactus is this one, and the one in use has a tick. Or from a terminal:

<p align="center">
<img src="../../docs/screenshots/tactus/setup-keyboard.png" width="45%" alt="Setup > Keyboard: Standard, and Tactus with a tick">
</p>

```
omamobile-osk use tactus # and back: omamobile-osk use squeekboard
omamobile-osk which
```

Both come with omamobile-shell's `omamobile-osk`, which starts the keyboard the owner chose (squeekboard instead, if Tactus fails at its start), and its `hypr/phone.lua` keeps Tactus's virtual keyboard out of the hardware-key binds, as it does squeekboard's. The choice is one word in `~/.config/omamobile/keyboard`. If Tactus is removed, the phone is back on squeekboard at the next start.

The package sits beside squeekboard: everything is under `/usr/lib/tactus`, with Stevia's settings schemas compiled there and the binary named `tactus`. (Arch's `stevia` package conflicts with squeekboard, which omamobile-shell needs.)

## What it does

- **Corrects a word when it is ended** (a space, a full stop, Return in running text). It weighs the word against what it could have been: where each finger landed in its key (a tap near a key's edge speaks for the neighbour), how common each word is, and the usual slips: two letters swapped, one missed or doubled, a missed space, a missing apostrophe (`dont`, `im`). A word the dictionary knows is replaced only when the taps themselves were close calls.
- **Backspace right after a correction puts back what was typed.** A word put back once is kept from then on (`~/.local/share/tactus/words.txt`).
- **Capitals:** a sentence starts with one, two spaces after a word make a full stop, a double tap on Shift locks it.
- **A long press** on a letter offers its accented forms. Held on the space bar, a slide moves the cursor. Backspace held deletes letters, then whole words.
- **An emoji page:** large emoji in four rows that slide sideways, the ones used lately first, a sign for each kind, a search by name, skin tones on a long press.
- **A microphone key** that starts the phone's dictation (`omamobile.voice`), and a swipe down that puts the keyboard away.
- **Past its round top corners the application shows,** not the wallpaper: the keyboard asks for a little less room than its panel is high (8 px on a screen 360 wide), so the window in front reaches that far under the panel's top. That much of the window's lower edge is behind the keyboard.
- It learns where the owner's fingers land (`~/.local/state/tactus/touch`) and shifts the keys' touch targets by it, within narrow limits.

Password fields get none of this: the typing engine is off wherever what is typed is hidden, and nothing typed into a field that asked for it (`sensitive data`) is learned.

## What it doesn't do

- **English only.** The dictionary is hunspell's en_US and the word counts are English. With another language's layout the keys type as they are, without corrections, and that has not been tried on a phone. There is no globe key and no way from Tactus to the shell's language sheet.
- **It corrects, it doesn't predict:** there is no row of suggestions. Stevia's own word completion is off: Tactus's settings default says so (`tactus.gschema.override`), and Stevia's hunspell completer looks for its dictionary under `/usr/lib/tactus` and finds none, which it says once at every start (`Failed to init default completer 'hunspell'`). That line in the journal is expected. Stevia's `osk-features` setting does nothing here: the keys are Tactus's own.
- It knows how common the 50,000 commonest words are. A slip in a rarer form of a common word (`corects`) can stay as typed.
- No Paste key (Omarchy's clipboard menu is on squeekboard's action row).
- **An application that doesn't say what its field is for gets corrections there too.** The typing engine runs only where a field's purpose is plain text (text-input's "normal"): a field that declares a password, a PIN, a number, a phone number, a name, an e-mail or web address, a date or a terminal gets each key as typed. But "normal" is also what a field that declares nothing reads as, so a GPUI editor or a terminal that doesn't say it is one is treated like a chat field. Backspace right after a correction puts the word back.
- **Not tried on the lock screen's password field.** The typing engine is off wherever the field says what is typed is hidden, as a password field should; whether the lock's field says so has not been checked on a phone, so until it has, unlock with squeekboard or the PIN pad if a password matters.
- The shell's home strip stays under it, as under squeekboard, so the microphone and emoji keys sit above the strip.

## Its colours

Tactus draws itself in the applied Omarchy theme, as squeekboard is styled: the panel in the theme's darker background, the keys in its lighter one, the letters in its foreground, the caret in its accent (from `~/.local/state/omarchy/current/theme/colors.toml`). When Omarchy applies another theme the keyboard takes the new colours at once (it watches `theme.generation`): the keyboard at the top of this page in Tokyo Night, and here a moment after `omarchy-theme-set catppuccin-latte`.

<p align="center">
<img src="../../docs/screenshots/tactus/theme-light.png" width="45%" alt="The same keyboard a moment after Omarchy applied Catppuccin Latte">
</p>

Without a theme file it uses light or dark colours of its own, by the desktop's setting. An owner who prefers those anyway can say so:

```
mkdir -p ~/.config/tactus && touch ~/.config/tactus/own-colours
```

## Text fields, and the browser

Every key is committed at once (no preedit), and the typing engine keeps its own copy of the text before the cursor.

- **A field that tells its text** (GTK, the browser) is held against that copy after every key. A word is replaced with `delete_surrounding_text`, and only once the field has shown everything sent before: a key that would take text away waits for that, a quarter of a second at most, and otherwise the word stays as typed.
- **A field that tells nothing** (GPUI applications) gets Backspace key presses and then the word. There the copy is built from Tactus's own keys alone, and any sign of life from the field that a key doesn't explain starts it afresh.
- **Chromium** (156, text-input-v3) sends new state only when the serial of the last `done` equals its count of commits, and Hyprland sends a text field `done` only when the keyboard commits something. Left alone, its surrounding text is one key behind, and since it takes text away counting from the cursor it last told of, a correction sent then deletes nothing and the right word lands after the wrong one. So Tactus answers: an empty input-method commit after a field's first sign of life and after every report that carries text (at most 40 a second). GTK applies nothing on an empty `done` and sends nothing back.

## The trace

`TACTUS_TRACE=1` in the keyboard's environment makes the typing engine say in the journal what it does and why: a word of so many letters kept or corrected, a field that tells its text or doesn't, a key that waited. It never says what was typed; `test/all --built` types a known text with the trace on and looks for it in the output.

## Tests

- `test/all` (offline; what `tests/packages` and CI run): the downloads are pinned, the patches are shaped as patches and touch the eleven files they should, the launcher, the licences.
- `test/all --upstream DIR`: the patches apply to the untouched Stevia tree with no fuzz.
- `test/all --built BUILD SRC` (the PKGBUILD's `check()`): the checks built with the keyboard. `tactus-typer-test` types against make-believe text fields (one that tells, one that tells nothing, a slow one, one that ignores deletes, a browser answered and unanswered): 126 checks. `tactus-ac-test` runs a list of slips and of words that must stay. Under `xvfb-run`, `tactus-kbd-test` and `tactus-emoji-test` drive the keys and the emoji page with no window on screen.

## Where it has run

On a Pixel 9a, as this package, chosen through Setup > Keyboard, in light on 2026-11-17 and in dark on 11-18: a GTK 3 text view (both days), Chromium 156 with text-input-v3 (a text area, an editable block and a one-line field: slips corrected, two spaces, Backspace, an emoji), and a GPUI application (a slip corrected, with the trace's line for it in a field that tells nothing). Changing to squeekboard and back from the menu worked both ways, and after each reboot the chosen keyboard was the one that started. It has been that phone's keyboard since. With the keyboard up the compositor kept 259 px for a panel 267 px high, the window in front ended 8 px under the panel's top, and no wallpaper showed past the corners, or between the window and the keyboard while the page changed from letters to emoji. Not tried: other languages' layouts, Qt applications, the lock screen's password field, a phone on its side, and any phone but the 9a.

## Licences

GPL-3.0-or-later, as Stevia (`COPYING`). The word counts (`en_50k.txt`) are from [FrequencyWords](https://github.com/hermitdave/FrequencyWords) by Hermit Dave, made from OpenSubtitles 2018, CC-BY-SA-4.0, installed unchanged; `WORD-COUNTS` has the commit. The emoji are the system's (Noto Color Emoji); the signs for their kinds and every icon on the keys are drawn in `tactus-draw.c`.
12 changes: 12 additions & 0 deletions packages/tactus/WORD-COUNTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The word counts (/usr/lib/tactus/share/phosh-osk-stevia/en_50k.txt)

How often each of the 50,000 commonest English words is seen, from
FrequencyWords by Hermit Dave (https://github.com/hermitdave/FrequencyWords,
content/2018/en/en_50k.txt at commit 34bb6447a96d4434dc2d4b24e0cf946c523090b3,
the first whose README gives the content's licence as CC-by-sa-4.0; the file
itself is the same since it was added at 072bbed282316a23651aa7068c7173aa7898cf80),
made from the OpenSubtitles 2018 corpus (http://opus.nlpl.eu/OpenSubtitles2018.php).
The file is installed unchanged.

Licence: Creative Commons Attribution-ShareAlike 4.0 International
(CC-BY-SA-4.0), https://creativecommons.org/licenses/by-sa/4.0/
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Subject: wayland: run where the compositor has no zphoc_device_state_v1

Stevia asks the compositor for phoc's device-state protocol (is a hardware
keyboard attached?) and counts it among the globals it can't do without, so
on a compositor without it the keyboard never becomes ready. Hyprland doesn't
have it. The protocol is now optional: without it there is no hardware
keyboard tracking, and everything else works.
---
--- a/src/pos-hw-tracker.c
+++ b/src/pos-hw-tracker.c
@@ -72,6 +72,9 @@
gpointer device_state)
{
self->device_state = device_state;
+ /* Not every compositor has it (Hyprland): no hardware keyboard tracking then */
+ if (!self->device_state)
+ return;
zphoc_device_state_v1_add_listener (self->device_state, &device_state_listener, self);
}

--- a/src/pos-wayland.c
+++ b/src/pos-wayland.c
@@ -387,6 +387,5 @@
self->zwlr_foreign_toplevel_manager_v1 &&
self->layer_shell &&
self->zxdg_output_manager_v1 &&
- self->zphoc_device_state_v1 &&
self->ext_data_control_manager);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Subject: build: the typing engine, the drawing and their tests

Adds Tactus's own sources to the library (tactus-autocorrect, tactus-draw,
tactus-typer), links hunspell for the dictionary, tells the code where the
package's data is (TACTUS_PKGDATADIR, for the word counts), and builds the
checks that run with no window on screen (tools/tactus-*-test).
---
--- a/meson.build
+++ b/meson.build
@@ -171,6 +171,7 @@
config_h.set_quoted('GETTEXT_PACKAGE', 'phosh-osk-stevia')
config_h.set_quoted('LOCALEDIR', localedir)
config_h.set_quoted('WORD_LIST', get_option('wordlist'))
+config_h.set_quoted('TACTUS_PKGDATADIR', pkgdatadir)
config_h.set_quoted('PHOSH_OSK_STEVIA_VERSION', meson.project_version())
config_h.set_quoted('POS_APP_ID', app_id)
config_h.set('POS_HAVE_FZF', fzf.found())
--- a/src/meson.build
+++ b/src/meson.build
@@ -20,6 +20,7 @@
libhandy_dep,
libsoup_dep,
libsystemd_dep,
+ hunspell_dep,
wayland_client_dep,
xkbcommon_dep,
cc.find_library('m', required: false),
@@ -34,6 +35,12 @@
)

libpos_sources = files(
+ 'tactus-autocorrect.c',
+ 'tactus-autocorrect.h',
+ 'tactus-draw.c',
+ 'tactus-draw.h',
+ 'tactus-typer.c',
+ 'tactus-typer.h',
'pos-app.c',
'pos-activation-filter.c',
'pos-activation-filter.h',
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -1,3 +1,17 @@


executable('pos-speech-test', 'pos-speech-test.c', dependencies: libpos_dep)
+
+# Tactus, checked with no window on screen
+executable('tactus-kbd-test', 'tactus-kbd-test.c', dependencies: libpos_dep)
+executable(
+ 'tactus-draw-test',
+ ['tactus-draw-test.c', '../src/tactus-draw.c'],
+ include_directories: include_directories('../src'),
+ dependencies: [dependency('pangocairo'), gio_dep, cc.find_library('m', required: false)],
+)
+executable('tactus-ac-test', 'tactus-ac-test.c', dependencies: libpos_dep)
+executable('tactus-typer-test', 'tactus-typer-test.c', dependencies: libpos_dep)
+executable('tactus-pages-test', 'tactus-pages-test.c', dependencies: libpos_dep)
+
+executable('tactus-emoji-test', 'tactus-emoji-test.c', dependencies: libpos_dep)
Loading