~earboxer/SwipeBehaviors

ref: 69ab83ab05443c11ca6633cd3ffba088602f5a98 SwipeBehaviors/predictor.sh -rwxr-xr-x 1.3 KiB
69ab83abZach DeCook predictor: fix multiple compound words 6 months ago
                                                                                
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
sock="$XDG_RUNTIME_DIR/predictor.sock"
lw="$XDG_RUNTIME_DIR/pred.lastword"
complete="$XDG_RUNTIME_DIR/pred.complete.bool"
words=~/.local/share/sxmo/words.txt
twow=~/.local/share/sxmo/count_2w.txt
keymap=~/.local/share/sxmo/keyboard.map.tsv
rm -f "$sock" "$lw" "$complete"
mkfifo "$sock"
saveWord(){
	IFS=''
	while read -r word; do
		echo "$word"
		word="$(printf "$word" |sed 's/^ //g' |tee "$lw")"
		rm -f "$complete"
		cat "$words" "$twow" | quick5 "$word" | sed 's/\t/ \t/g'|sed 's/$/ /g' >> "$sock"
	done
}
typeSomehow(){
	IFS=''
	while read -r word; do
		if test -e "$complete"; then
			test -n "${word:1}" && wtype -- "${word:1}"
		else
			wtype -- "$word"
		fi
	done
}
cat 0<> "$sock"|suggpicker 2>/dev/null|saveWord | typeSomehow &
IFS=''
while read -r swipe; do
	if test -n "${swipe:1}"; then
		touch "$complete"
		# TODO: change words
		echo "$swipe" | swipeGuess "$words" 5 >> "$sock"
	else
		if test "$swipe" = " "; then
			if test -e "$lw"; then
				printf " " >> "$lw"
				rm -f "$complete"
				cat "$twow" | quick5 "$(cat "$lw")" >> "$sock"
				rm -f "$lw"
			fi
		elif test "$swipe" = "$(echo -e "\x08")"; then
			rm -f "$lw"
		elif test "$swipe" = "$(echo -e "\n")"; then
			rm -f "$lw"
		else
			printf "$swipe" >> "$lw"
		fi
	fi
done
killall suggpicker