about summary refs log tree commit diff
path: root/sb_picker.sh
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2022-06-29 07:59:58 -0400
committerZach DeCook <zachdecook@librem.one>2022-06-29 07:59:58 -0400
commit1a18ec96509414fc4f2e297fb8901f038a412f0c (patch)
treebeb57dbe6dbe040bb05888e01029b069dc6505b4 /sb_picker.sh
parentf604553cec7f06998c3c3b89d702bccd92ca9e57 (diff)
downloadSwipeBehaviors-1a18ec96509414fc4f2e297fb8901f038a412f0c.tar.gz
rename behavior scripts for consistency
Diffstat (limited to 'sb_picker.sh')
-rwxr-xr-xsb_picker.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/sb_picker.sh b/sb_picker.sh
new file mode 100755
index 0000000..69dda6e
--- /dev/null
+++ b/sb_picker.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+sock="$XDG_RUNTIME_DIR/sgp.sock"
+words=~/.local/share/sxmo/words.txt
+keymap=~/.local/share/sxmo/keyboard.map.tsv
+rm "$sock"
+mkfifo "$sock"
+cat 0<> "$sock"|suggpicker 2>/dev/null|completelyTypeWord.sh &
+swipeGuess "$words" 5 | while read -r word; do
+	set -- $word
+	if test -n "$2"; then
+		s1="$(echo "$1" | mapScore "$keymap" bee|cut -f1)"
+		s2="$(echo "$2" | mapScore "$keymap" bee |cut -f1)"
+		cutoff="$(( ($s1 * 19 / 20) - 2 ))"
+		if [ "$s2" -lt "$cutoff" ]; then
+			set -- "$1"
+		elif [ -n "$4" ]; then
+			s4="$(echo "$4" | mapScore "$keymap" bee |cut -f1)"
+			if [ "$s4" -lt "$cutoff" ]; then
+				set -- "$1" "$2" "$3"
+			fi
+		fi
+	fi
+	if test "$1" && ! test "$2"; then
+		wtype "${1:1}"
+	elif ! test "$2"; then
+		echo "" >> "$sock"
+	else
+		echo "$word" >> "$sock"
+	fi
+done
+
+killall suggpicker