summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-11-25 03:45:16 -0800
committerHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-11-25 03:45:16 -0800
commitcb31a5025127f8e16c705c88f439a8f819952827 (patch)
treec84a83e6c50bc9d783e7d6d08d109602bf1a03aa
Moved everything out of dotfiles
-rw-r--r--README45
-rwxr-xr-xbimt62
-rwxr-xr-ximl5
-rwxr-xr-xims58
-rwxr-xr-ximt55
5 files changed, 225 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..ed5ac16
--- /dev/null
+++ b/README
@@ -0,0 +1,45 @@
+Janky ime for Boshiamy using only busybox commands and xdotool/termux. If ibus
+breaks you will have many backup options for using boshiamy (or any other
+ibus-table based input method)
+
+-------------------------=[Requirements for everything]=------------------------
+busybox
+
+assume that you have the boshiamy input source file at
+ ~/lang/zh/boshiamy/ibus-boshiamy/boshiamy.txt
+ from https://github.com/jdh8/ibus-boshiamy
+-----------------------------=[Different Variants]=-----------------------------
+tmux Based Input (imt)
+ requires tmux and busybox, as well as a terminal that can display
+ Chinese. Create two panes. In the second pane launch imt, it will pass
+ all input into the previously active pane, including arrow keys and
+ backspace.
+
+ Pressing any letter will display the characters for that code, pressing
+ space or one of the number keys will select the character. pressing '`'
+ will clear the character input buffer. pressing space or 0-9 without
+ anything in the input buffer will pass that onto the previous window.
+
+ NOTE: If you put the im panel at the bottom of your tmux window you will
+ be able to access it from multiple other panels:
+
+ +--------+--------+--------+
+ |Panel 1 | Panel 2| Panel 3|
+ +--------+--------+--------+
+ |im panel |
+ +--------+--------+--------+
+
+tmux Based Input with Braille Display (bimt)
+ Same as above, except that it will also display the candidate characters
+ using bbrll (see https://hairydiode.xyz/cgit/bbrll). Assumes that textd
+ is in the path somewhere, as well bdf fonts in "~/lang/fonts/12"
+
+Window Manager Based Input (iml, ims)
+ requires [xdotool] and a terminal of some sort, current script uses st but
+ any terminal that can display chinese is fine.
+
+ have your window manager launch the script iml, and it will launch the
+ input method in a new terminal window and redirect the output to the
+ previously focused terminal window
+
+
diff --git a/bimt b/bimt
new file mode 100755
index 0000000..4bef88f
--- /dev/null
+++ b/bimt
@@ -0,0 +1,62 @@
+#!/bin/bash
+#Janky ibus table boshiamy implementation for tmux, this variant prints
+#characters using braille display
+
+#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
+ #because the braille font display is incredibly slow, truncate
+ # to first 5 options, this is unicode aware
+ opt=${opt:0:5}
+ #send options to textd for braille display, 8x8 bdf fonts
+ #assumed to be here
+ echo $opt | textd ~/lang/fonts/12
+ elif [[ "$i" = [0123456789] ]]; then
+ if [ "$code" == "" ]; then
+ char=$i
+ else
+ clear
+ char=$(echo $opt | awk "{print \$$i}")
+ code=""
+ fi
+ tmux send-key -t "!" "$char"
+ #dirty hack for detecting space
+ elif [ "<$i>" == "< >" ]; then
+ if [ "$code" == "" ]; then
+ char=" "
+ else
+ clear
+ char=$(echo $opt | awk "{print \$1}")
+ code=""
+ fi
+ tmux send-key -t "!" "$char"
+ elif [[ "$i" = '`' ]]; then
+ clear
+ code=""
+ #if enter is pressed then I am done editing
+ elif [[ "$i" = "" ]]; then
+ #-r "!" means the previous window
+ tmux send-keys -t "!" Enter
+ else
+ tmux send-key -t "!" "$i"
+ fi
+done
diff --git a/iml b/iml
new file mode 100755
index 0000000..6058178
--- /dev/null
+++ b/iml
@@ -0,0 +1,5 @@
+#!/bin/bash
+#launches the im in a floating terminal window
+win=$(xdotool getactivewindow)
+st -e ims "$win" &
+exit
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
diff --git a/imt b/imt
new file mode 100755
index 0000000..07de6bb
--- /dev/null
+++ b/imt
@@ -0,0 +1,55 @@
+#!/bin/bash
+#Janky ibus table boshiamy implementation for tmux
+
+#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
+ tmux send-key -t "!" "$char"
+ #dirty hack for detecting space
+ elif [ "<$i>" == "< >" ]; then
+ if [ "$code" == "" ]; then
+ char=" "
+ else
+ clear
+ char=$(echo $opt | awk "{print \$1}")
+ code=""
+ fi
+ tmux send-key -t "!" "$char"
+ elif [[ "$i" = '`' ]]; then
+ clear
+ code=""
+ #if enter is pressed then I am done editing
+ elif [[ "$i" = "" ]]; then
+ #-r "!" means the previous window
+ tmux send-keys -t "!" Enter
+ else
+ tmux send-key -t "!" "$i"
+ fi
+done