Simple utility to turn swipes into words -- "plugin" for wvkbd to enable swipe-typing under wayland SXMO.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

swipeToQuery(){
	swipe=$(echo "$1" | tr -d "'")
	printf '^'
	printf "${swipe:0:2}"
	if test "${swipe:2}"; then
		printf "${swipe:2}" |grep -o . | xargs -I{} printf '\?%s' "{}"
	fi
	printf '$'
}

query(){
	swipe="$2"
	wordlist="$1"

	query=$(swipeToQuery "$swipe")
	echo "query: $query" > /dev/stderr
	# -m 1: just give first result
	grep -m 1 "$query" "$wordlist"
}

while read -r line; do
	test "$line" && query "$1" "$line" && printf '\n'
done