summaryrefslogtreecommitdiff
path: root/ims
diff options
context:
space:
mode:
Diffstat (limited to 'ims')
-rwxr-xr-xims58
1 files changed, 58 insertions, 0 deletions
diff --git a/ims b/ims
new file mode 100755
index 0000000..9571158
--- /dev/null
+++ b/ims
@@ -0,0 +1,58 @@
+#!/bin/bash
+#meant to be opened as an i3 floating terminal window, launch with iml script
+
+#gets current window id of IME and puts it here
+code=""
+clear
+while true; do
+ #need IFS="" so read reads spaces
+ OIFS=$IFS
+ export IFS=""; read -rsn1 i
+ export IFS=$OIFS
+ #echo ".$i."
+ if [[ "$i" = [abcdefghijklmnopqrstuvwxyz,.] ]]; then
+ clear
+ #escape periods
+ i=$(echo $i |sed 's/\./\\\./g')
+ code=$code$i
+ opt=$(grep "^$code\s" ~/lang/zh/boshiamy/ibus-boshiamy/boshiamy.txt |\
+ #remove simplfied
+ grep -v 98|\
+ awk '{print $3" "$2}' |\
+ sort -nr|\
+ awk '{print $2}')
+ echo $opt
+ echo $code
+ elif [[ "$i" = [0123456789] ]]; then
+ if [ "$code" == "" ]; then
+ char=$i
+ else
+ clear
+ char=$(echo $opt | awk "{print \$$i}")
+ code=""
+ fi
+ imeboxid=$(cat /tmp/imeboxid)
+ xdotool type --window "$1" "$char"
+ #dirty hack for detecting space
+ elif [ "<$i>" == "< >" ]; then
+ if [ "$code" == "" ]; then
+ char=" "
+ else
+ clear
+ char=$(echo $opt | awk "{print \$1}")
+ code=""
+ fi
+ xdotool type --window "$1" "$char"
+ #delete, too lazy to do control characters
+ elif [[ "$i" = '`' ]]; then
+ clear
+ #code=${code::-1}
+ code=""
+ #if enter is pressed then I am done and want to return to the previous
+ #window
+ elif [[ "$i" = "" ]]; then
+ xdotool windowfocus $1
+ else
+ xdotool type --window "$1" "$i"
+ fi
+done