diff options
| author | Zach DeCook <zachdecook@librem.one> | 2022-05-17 09:12:56 -0400 |
|---|---|---|
| committer | Zach DeCook <zachdecook@librem.one> | 2022-05-17 09:46:26 -0400 |
| commit | 7a2afa7313579cf2456fe82912cd90d1d8ac2f09 (patch) | |
| tree | 75b069f03eeb658fca5f9d737b943c9d26745e98 /predictor.sh | |
| parent | 88dbe5d4d781a67c7de6732c56fa86ac22ac8c57 (diff) | |
| download | SwipeBehaviors-7a2afa7313579cf2456fe82912cd90d1d8ac2f09.tar.gz | |
predictor: more consistent compound behavior
Diffstat (limited to 'predictor.sh')
| -rwxr-xr-x | predictor.sh | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/predictor.sh b/predictor.sh index ccbb21f..0a5a932 100755 --- a/predictor.sh +++ b/predictor.sh @@ -1,6 +1,7 @@ #!/bin/sh sock="$XDG_RUNTIME_DIR/predictor.sock" lw="$XDG_RUNTIME_DIR/pred.lastword" +tw="$XDG_RUNTIME_DIR/pred.tfw" complete="$XDG_RUNTIME_DIR/pred.complete.bool" words=~/.local/share/sxmo/words.txt twow=~/.local/share/sxmo/count_2w.txt @@ -11,9 +12,16 @@ saveWord(){ IFS='' while read -r word; do echo "$word" - word="$(printf "$word" |sed 's/^ //g' |tee "$lw")" + if test "${word:0:1}" = " "; then + printf " " >> "$lw" + mv "$lw" "$tw" + word="$(printf %s "${word:1}"| tee "$lw")" + else + printf %s "$word" >> "$lw" + word="$(cat "$lw")" + fi rm -f "$complete" - cat "$words" "$twow" | quick5 "$word" | sed 's/\t/ \t/g'|sed 's/$/ /g' >> "$sock" + cat "$words" "$twow" | quick5 "$word" >> "$sock" done } typeSomehow(){ @@ -39,15 +47,15 @@ while read -r swipe; do printf " " >> "$lw" rm -f "$complete" cat "$twow" | quick5 "$(cat "$lw")" >> "$sock" - rm -f "$lw" + mv "$lw" "$tw" fi elif test "$swipe" = "$(echo -e "\x08")"; then lastword="$(cat "$lw")" printf %s "$lastword" | sed 's/.$//g' > "$lw" elif test "$swipe" = "$(echo -e "\n")"; then - rm -f "$lw" + rm -f "$lw" "$tw" else - printf "$swipe" >> "$lw" + printf %s "$swipe" >> "$lw" fi fi done |
