summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-06-29 12:15:01 -0700
committerHaoran S. Diao (刁浩然) <0@hairydiode.xyz>2023-06-29 12:15:01 -0700
commitf511ce8ec7309fd75d574b820d08518c90ab3c4a (patch)
tree08002d20e691040aad241ed9253940022df77ca0
parent4c3eafd541061856c965121c3105b462d4c60b1c (diff)
tmux based script, way less embarassing
-rw-r--r--cont/jankime.html56
-rw-r--r--jankime.html56
2 files changed, 26 insertions, 86 deletions
diff --git a/cont/jankime.html b/cont/jankime.html
index 96241dc..4d9623f 100644
--- a/cont/jankime.html
+++ b/cont/jankime.html
@@ -4,7 +4,7 @@
--------------------------------------------------------------------------------
[SETTITLE]Janky IME
[SETDATE]6-29-2023
-
+UPDATE: This IME is now tmux based, old xdotool version is still <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/ims">here</a>
A new python version came out, so of course that means every python package on
my rolling-release system has broken. This includes ibus, which I need for my
input method. I'm currently running some web-crawling scripts that I don't want
@@ -43,24 +43,12 @@ The Implementation:
and xorg, and it needs to work on all programs running in the terminal
regardless of whether they used cooked input(bash) or raw input(vim)
- So what I ended up on is a bash script that runs in a seperate st
- terminal window, which uses grep to find the character, and inputs it
- using xdotool.
-
- First we have a script that called with a desktop environment shortcut
- (in my case i3), that finds the current xorg window id, and launches the
- ime in seperate st window, with the current xorg window id as the only
- argument for the ime script
+ So what I ended up on is a bash script that runs in a seperate tmux
+ panel and sends input to the previously active panel
- <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/iml">CODE:</a>
- #!/bin/bash
- win=$(xdotool getactivewindow)
- st -e ims "$win" &
- exit
-
Input is read with read in a loop
- <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/ims">CODE:</a>
+ <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/imt">CODE:</a>
OIFS=$IFS
export IFS=""; read -rsn1 i
IFS=$OIFS
@@ -68,16 +56,13 @@ The Implementation:
IFS="" is done to make it read spaces as input, but this makes this
implementation very brittle and probably not portable depending on bash
versions. This also passes along control and special characters such as
- delete and move left, but differences in how these sequences are
- interpreted as xinput input for the terminal vs. for terminal programs,
- as well as differences between terminal emulators means that this
- doesn't work very well. For vim on cool-retro-term for exampple, tab,
- escape and the arrow keys work, but backsapce is interpreted as a delete
+ delete and move left, and it seems tmux handles most of these
+ differences
I then simple run grep ^$code\s, rearrange the columns with awk, sort,
then take out the ranking column
- <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/ims">CODE:</a>
+ <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/imt">CODE:</a>
opt=$(grep "^$code\s" ~/lang/zh/boshiamy/ibus-boshiamy/boshiamy.txt |\
#remove simplfied
grep -v 98|\
@@ -86,7 +71,7 @@ The Implementation:
awk '{print $2}')
finally, it inputs the selected character if the input is 1-9 or Space,
- using xdotool and the windowid of the original window. Note that bash
+ using tmux send-keys on the previously active pane. Note that bash
variables don't sort newlines, so the conversion of the input characters
from line seperated to space seperated was done for free. However this
makes the code less portable
@@ -96,23 +81,8 @@ The Implementation:
...
xdotool type --window "$1" "$char"
-Downsides:
- Obviously this implementation sucks, but it's meant to be a backup for
- when all I have working are bash and xorg
-
- One issue is that xdotool seems to have a fair bit of latency, and on
- certain terminal combinations seems to skip input alltogether, I think
- fiddling with the input delay argument in the future might fix this.
-
- Another is that this method won't work on things like browsers, because
- they only take input when in focus (at least on my desktop environment).
-
-The Future:
- What I really wanted to make initially was essentially tmux with an
- input method , where I would run a bash script in a terminal that would
- itself pretend to be a terminal, and pass along input after going
- through an input method. This would've had the added benefit of running
- in the Linux console as well (although by default the linux console can
- not display fonts with more than 512 characters). The output could've
- also been processed such that it is displayed with brailled unicode
- characters, which would've fixed the font issue
+Downsides/The Future:
+ This works in the linux console but obviously the linux console has
+ limitations on what text it can display(by default the linux console can
+ not display fonts with more than 512 characters). I think I'm gonna
+ write a bash based cbrll implemntation and a character displayer as well
diff --git a/jankime.html b/jankime.html
index d65585a..2abddec 100644
--- a/jankime.html
+++ b/jankime.html
@@ -20,7 +20,7 @@
123456789-223456789-323456789-423456789-523456789-623456789-723456789-8234567890
一二三四-->Janky IME 6-29-2023
--------------------------------------------------------------------------------
-
+UPDATE: This IME is now tmux based, old xdotool version is still <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/ims">here</a>
A new python version came out, so of course that means every python package on
my rolling-release system has broken. This includes ibus, which I need for my
input method. I'm currently running some web-crawling scripts that I don't want
@@ -59,24 +59,12 @@ The Implementation:
and xorg, and it needs to work on all programs running in the terminal
regardless of whether they used cooked input(bash) or raw input(vim)
- So what I ended up on is a bash script that runs in a seperate st
- terminal window, which uses grep to find the character, and inputs it
- using xdotool.
-
- First we have a script that called with a desktop environment shortcut
- (in my case i3), that finds the current xorg window id, and launches the
- ime in seperate st window, with the current xorg window id as the only
- argument for the ime script
+ So what I ended up on is a bash script that runs in a seperate tmux
+ panel and sends input to the previously active panel
- <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/iml">CODE:</a>
- #!/bin/bash
- win=$(xdotool getactivewindow)
- st -e ims "$win" &
- exit
-
Input is read with read in a loop
- <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/ims">CODE:</a>
+ <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/imt">CODE:</a>
OIFS=$IFS
export IFS=""; read -rsn1 i
IFS=$OIFS
@@ -84,16 +72,13 @@ The Implementation:
IFS="" is done to make it read spaces as input, but this makes this
implementation very brittle and probably not portable depending on bash
versions. This also passes along control and special characters such as
- delete and move left, but differences in how these sequences are
- interpreted as xinput input for the terminal vs. for terminal programs,
- as well as differences between terminal emulators means that this
- doesn't work very well. For vim on cool-retro-term for exampple, tab,
- escape and the arrow keys work, but backsapce is interpreted as a delete
+ delete and move left, and it seems tmux handles most of these
+ differences
I then simple run grep ^$code\s, rearrange the columns with awk, sort,
then take out the ranking column
- <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/ims">CODE:</a>
+ <a href="https://hairydiode.xyz/cgit/dotfiles.git/tree/scripts/imt">CODE:</a>
opt=$(grep "^$code\s" ~/lang/zh/boshiamy/ibus-boshiamy/boshiamy.txt |\
#remove simplfied
grep -v 98|\
@@ -102,7 +87,7 @@ The Implementation:
awk '{print $2}')
finally, it inputs the selected character if the input is 1-9 or Space,
- using xdotool and the windowid of the original window. Note that bash
+ using tmux send-keys on the previously active pane. Note that bash
variables don't sort newlines, so the conversion of the input characters
from line seperated to space seperated was done for free. However this
makes the code less portable
@@ -112,26 +97,11 @@ The Implementation:
...
xdotool type --window "$1" "$char"
-Downsides:
- Obviously this implementation sucks, but it's meant to be a backup for
- when all I have working are bash and xorg
-
- One issue is that xdotool seems to have a fair bit of latency, and on
- certain terminal combinations seems to skip input alltogether, I think
- fiddling with the input delay argument in the future might fix this.
-
- Another is that this method won't work on things like browsers, because
- they only take input when in focus (at least on my desktop environment).
-
-The Future:
- What I really wanted to make initially was essentially tmux with an
- input method , where I would run a bash script in a terminal that would
- itself pretend to be a terminal, and pass along input after going
- through an input method. This would've had the added benefit of running
- in the Linux console as well (although by default the linux console can
- not display fonts with more than 512 characters). The output could've
- also been processed such that it is displayed with brailled unicode
- characters, which would've fixed the font issue
+Downsides/The Future:
+ This works in the linux console but obviously the linux console has
+ limitations on what text it can display(by default the linux console can
+ not display fonts with more than 512 characters). I think I'm gonna
+ write a bash based cbrll implemntation and a character displayer as well
</pre>
</div>
<br>