about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xpredictor.sh9
1 files changed, 7 insertions, 2 deletions
diff --git a/predictor.sh b/predictor.sh
index 91e7ffc..0ce7b44 100755
--- a/predictor.sh
+++ b/predictor.sh
@@ -8,14 +8,16 @@ keymap=~/.local/share/sxmo/keyboard.map.tsv
 rm -f "$sock" "$lw" "$complete"
 mkfifo "$sock"
 saveWord(){
+	IFS=''
 	while read -r word; do
-		printf "$word" > "$lw"
 		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}"
@@ -25,13 +27,14 @@ typeSomehow(){
 	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 "$swipe" = " "; then
 			if test -e "$lw"; then
 				printf " " >> "$lw"
 				rm -f "$complete"
@@ -40,6 +43,8 @@ while read -r swipe; do
 			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