plugins for wvkbd using swipeGuess
predictor: initial somewhat working draft
Zach DeCook 2022-05-14
parent 3f4151f · commit 0f8114d
-rwxr-xr-xpredictor.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/predictor.sh b/predictor.sh
new file mode 100755
index 0000000..6a4083e
--- /dev/null
+++ b/predictor.sh
@@ -0,0 +1,44 @@
+#!/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(){
+ while read -r word; do
+ printf "$word" > "$lw"
+ echo "$word"
+ done
+}
+typeSomehow(){
+ 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 &
+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
+ rm -f "$complete"
+ word="$(cat "$lw")"
+ grep -i -m 5 "^$word " "$twow" |awk '(1){printf $2"\t"} END{print ""}' >> "$sock"
+ rm -f "$lw"
+ fi
+ else
+ printf "$swipe" >> "$lw"
+ fi
+ fi
+done
+killall suggpicker