📜 ⬆️ ⬇️

X Neural Switcher - Cookbook

Greetings.

I am the author of the program to automatically switch the keyboard layout, working under Linux. This program is xneur or X Neural Switcher .

When I started this program, there was nothing supposed to replace Punto Swither for linux. Please note, I wrote it for myself personally, almost everything always works for me. I share it only because the program is useful to people.
')
In future articles, I will examine the existing (and existing) counterparts, and explain why they are all that you can not use, and what a cool program xneur.

I’m doing the program on the strength of one hour a week, so it’s silly to blame me for slow development. I make money also by programming, but not at all related to linux.

Over the past 6 years, I occasionally stumbled upon specific bugs like Xlib and DE, which I had to find mutual understanding with.

Now I want to talk about the preparation of xneur, describe the settings and share "little football tricks."

This part of the articles under the number 0 is devoted to the simplest - the description. You'd be surprised how much xneur knows from what Punto can't.

For those who have tried for a long time, but not mastered. I am always open to dialogue. If something does not work somewhere, let me know all the necessary information, and I will try to solve your problem.

What is X Neural Switcher.



X Neural Switcher - a program to automatically switch keyboard layouts, depending on the typed text. Those. when typing, if it is typed in the wrong layout, xneur will automatically (or upon request) switch the language to the desired one.

When working in automatic mode, xneur automatically determines the layout of the entered text and changes the language for you. In this mode, it is possible to set exclusion applications, in which the automatic mode will be replaced with manual mode.

When working in manual mode, xneur does not track the dialing, but allows you to automatically change the layout of the last typed word (Pause / Break button), the last typed line (Ctrl + Break key combination), the selected text (Shift + Break key combination) and other useful functions.

All the above shortcuts work in automatic mode. If for any reason you are not satisfied with the pre-configured combinations, you can always change them in the program settings. The program also allows you to create your own shortcut keys to run any applications.

Currently, the program supports eighteen languages: Armenian, Belarusian, Bulgarian, Czech, Georgian, German, Greek, English, Estonian, French, Kazakh, Lithuanian, Latvian, Polish, Moldavian (Romanian), Russian, Spanish, Ukrainian and Uzbek.

For the above languages, the program has heuristic analysis algorithms, but, nevertheless, the program can work with other languages ​​if there are aspell or myspell dictionaries for it.

The main features of the program.



Thus, if you master the fine tuning, you will always cook the xneur to your liking.

Program installation.


The source texts of the latest versions of xneur and gxneur are available at xneur.ru/downloads

To install from source, you will need the following packages (I’ll give you a way to install packages for Ubuntu, but you will understand what you need to install):
sudo apt-get install build-essential automake1.9 libtool flex libx11-dev libgstreamer0.10-dev libopenal-dev libpcre3-dev libnotify-dev zlib1g-dev libaspell-dev libxosd-dev libenchant-dev
To build gxneur (interface for configuration) you still need to install these packages:
sudo apt-get install libglade2-dev libgtk2.0-dev libgconf2-dev libappindicator-dev

Installation is carried out by a standard set of commands (again, I quote for Ubuntu).
 ./configure make sudo make install 

To remove a program installed in this way, you can use the command
 sudo make uninstall 


Now we will analyze the program configuration options, in case you have some packages missing or you just want to disable them.

For reference, you can use ./configure --help.

But since it’s too lazy to compile a program from source, I have two PPAs for Ubuntu users.

sudo add-apt-repository ppa:andrew-crew-kuznetsov/xneur-stable
sudo add-apt-repository ppa:andrew-crew-kuznetsov/xneur-unstable

The first repository contains basic releases, the second contains rolling releases (nightly builds).

Description of configuration parameters.


Now let's look at what will allow us to fine-tune xneur, namely its configuration file.
We analyze it on the options. I will give a brief description of each option and explain in which cases it is better to use it.

Version 0.15.0
Describes the current version of the program. For the most part, generally does not affect anything.

ManualMode No
Manual mode option. If set to Yes, automatic switching will be disabled everywhere, except for the applications specified in the corresponding setting.

Loglevel trace
The level of messages that xneur will pour into the console.
Error is only an error.
Warning - previous, plus warnings about problems that do not affect the operation of the program.
Log - previous, plus a little more.
Debug - the previous, plus debug messages of the program.
Trace - the previous one, plus generally everything that happens in xneur.

ExcludeLanguage de
The option allows multiple applications and serves to indicate the layout with which and to which the switching will not be carried out.

DefaultXkbGroup 0
Defines the default layout for newly launched applications.

ExcludeApp rdesktop
With this option, you can completely exclude the application from processing. Multiple use is allowed.

SetAutoApp Gedit
This option defines applications in which the automatic switching mode will be forcibly enabled, regardless of the ManualMode option.

SetManualApp Anjuta
This option defines applications in which manual switching mode will be forcibly enabled, regardless of the ManualMode option.

AddBind Action Key
Defines a key for an action to switch layouts or other things. The Action list is in your configuration file.

AddAction Control Alt f Firefox Browser firefox
Defines a key to perform a custom action.

ReplaceAbbreviation ini Andrey Crew Kuznetsov
Defines a list of abbreviations for substitution abbreviations.

ReplaceAbbreviationIgnoreLayout Yes
Determines whether to consider the current layout when replacing abbreviations. If set to Yes, the program will replace the abbreviation “q” and “qw” with “ytsuken”.

PlaySounds No
Turns the soundtrack on or off.

SoundVolumePercent 15
Determines the volume of the program sounds as a percentage of the system volume.

AddSound AutomaticChangeWord Enable /usr/share/xneur/sounds/itemback.wav
This option indicates for which action and which sound to use. The list of actions for which you can hang the notification is in your configuration file.

EducationMode Yes
It's simple. Whether or not to include a self-learning program for your lexicon.

LayoutRememberMode Yes
Remember layout for each window or one layout for all windows? You decide.

LayoutRememberModeForApp Wine
This option will force xneur to use the same layout for all application windows. I have a common layout everywhere in Wine.

SaveSelectionMode Yes
You selected and changed the text with xneur. If this option is enabled, the selection will remain after the change, making it possible to further switch.

RotateLayoutAfterChangeSelectedMode No
Determine whether to switch the system layout, if the selected text is corrected.

SendDelay 0
The delay before sending the intercepted keystroke back to the application.

Logsave yes
Turn on the keylogger, i.e. save the typed text to a file.

Logsize 10,000,000
We determine the size of the file with logs (in bytes).

LogMail to_me@mail.ru
If the option is defined, then the log of the typed text will be sent to this email.

LogHostIP 127.0.0.1
Host that provides email services (mail server for sending, which does not require a login and password). Perhaps the indication is not ip, and the name.

LogPort 25
Port mail server.

CorrectIncidentalCaps Yes
Option to correct a random caps.

CorrectTwoCapitalLetter Yes
Option to correct TWO capital letters.

CorrectCapitalLetterAfterDot Yes
Corrects a lowercase letter in uppercase after a dot or exclamation point.

CorrectTwoSpaceWithCommaAndSpace Yes
Fix double space for comma.

CorrectTwoMinusWithDash Yes
Fixes a double minus on the dash.

CorrectCWithCopyright Yes
Fixes © on ©

CorrectTMWithmark Yes
Corrects (tm) on ™.

CorrectRWithRegistered Yes
Corrects ® on ®.

FlushBufferWhenPressEscape Yes
If this option is enabled, then when you press Escape, the internal toggle buffer will be reset.

FlushBufferWhenPressEnter No
If this option is enabled, then when pressing Enter, the internal switching buffer will be reset.

DontProcessWhenPressEnter No
The word will not be processed if Enter is pressed, which is convenient in messengers.

ShowOSD No
Show on-screen messages. Outdated

FontOSD - * - * - * - * - * - * - 32 - * - * - * - * - * - * - u
Font selection for screen messages. Outdated

AddOSD XneurStart Enable X Neural Switcher launched
This option indicates for which action and which screen message to use. The list of actions for which you can hang the notification is in your configuration file.

ShowPopup Yes
Show popup messages.

PopupExpireTimeout 1500
Interval display pop-up messages. In this implementation, the display library does not work.

AddPopup XneurStart Enable X Neural Switcher launched
This option indicates for which action and which pop-up message to use. The list of actions for which you can hang the notification is in your configuration file.

CheckOnProcess Yes
Check the word on the fly or after clicking Entrer. I prefer on the fly.

DisableCapsLock Yes
Disable caps completely.

CorrectSpaceWithPunctuation No
Remove spaces before punctuation.

Autocompletion Yes
Enable word completion.

AddSpaceAfterAutocompletion No
Add space after autocompletion.

AutocompletionExcludeApp Gnome-terminal
In these applications, auto-completion will be disabled.

TroubleshootBackspace No
Disable autoswitch if backspace is pressed.

TroubleshootLeftArrow Yes
Disable autoswitch if left arrow is pressed.

TroubleshootRightArrow Yes
Disable autoswitch if the right arrow is pressed.

TroubleshootUpArrow Yes
Disable autoswitch if the up arrow is pressed.

TroubleshootDownArrow Yes
Disable autoswitch if down arrow is pressed.

TroubleshootDelete No
Disable autoswitch if Delete is pressed.

TroubleshootSwitch Yes
Disable autoswitch if you switch layout.

TroubleshootFullScreen Yes
Disable autoswitch if the application is in full screen mode.

CompatibilityWithCompletion Yes
Crutch for compatibility with autocompletion in other applications.

TrackingInput Yes
Disabling this option will lead to a complete failure of the program to intercept the keyboard.

TrackingMouse Yes
Disabling this option will lead to a complete failure of the program to intercept the mouse.

DontSendKeyRelease No
Do not send a KeyRelease keyboard event. Very specific thing, it is better not to change the value of the option.


What's next?


In the future I plan to talk about:
  • Algorithms xneur.
  • Xneur as a keylogger, with an example of a working config.
  • Well and other interesting about xlib, programs under linux and all that.


Following parts


X Neural Switcher - Cookbook (Part 1). Forerunners and analogues
X Neural Switcher - Cookbook (Part 2). Algorithms

Source: https://habr.com/ru/post/132635/


All Articles