~earboxer/SwipeBehaviors

7a2afa7313579cf2456fe82912cd90d1d8ac2f09 — Zach DeCook 4 months ago 88dbe5d
predictor: more consistent compound behavior
1 files changed, 13 insertions(+), 5 deletions(-)

M predictor.sh
M predictor.sh => predictor.sh +13 -5
@@ 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