Automatic layout change if you enter text and forget to change Russian to English or vice versa. First of all, let's configure X11, or rather keyboard processing:
- https://norvig.com/mayzner.html downloads N-gram.
- Since I did not find an N-gram for the Russian language, we will teach ourselves. Download about 20-30 books in Russian and English.
- generate frequencies. I have a program and a script configured for the first 5 characters (5-gram) (If you are lazy, they are in the repository. xz -d ngram_stats_en.h.xz - to unpack)
python genru3.py book-ru/* > ngram_stats_ru.h
python genen3.py book-en/* > ngram_stats_en.h
- Manual configuration in the code, replace the address of your keyboard/event4 with yours. You can find the path with the command:
sudo cat /proc/bus/input/devices | grep -A5 -i "Keyboard"
And set the read beat
sudo chmod a+r /dev/input/event*
- Package build: gcc enru_change.c -o enru_change $(pkg-config --cflags --libs gtk+-3.0 appindicator3-0.1) -lX11 -lXtst -lpthread
Implemented:
- change the layout en\ru
- replace entered incorrect characters
- press the right Alt then the next word will be entered without auto-replacement \ If you press the Right and Left Alt, then until canceled by the same combination, auto-replacement is disabled.
Result: First line - I want to enter this line Second line - how the program worked
(Entered) Z wanted ...
(result) I wanted to write this text with the correct layout
Yes, it is not ideal, but we are working on the algorithm and training the model