「Interception-tools」の版間の差分
(冒頭を翻訳) |
(→インストール: 翻訳) |
||
15行目: | 15行目: | ||
== インストール == |
== インストール == |
||
− | + | {{Pkg|interception-tools}} を[[インストール]]してください。 |
|
+ | 利用可能なプラグインはたくさんあります: |
||
− | Many plugins are available: |
||
− | * {{Pkg|interception-caps2esc}} |
+ | * {{Pkg|interception-caps2esc}} ({{ic|Ctrl}}/{{ic|Esc}} で {{ic|CapsLock}} を切り替える) |
* {{AUR|interception-caps2esc-delay-git}} |
* {{AUR|interception-caps2esc-delay-git}} |
||
* {{AUR|interception-caps2esc-nocaps-git}} |
* {{AUR|interception-caps2esc-nocaps-git}} |
||
− | * {{Pkg|interception-dual-function-keys}} |
+ | * {{Pkg|interception-dual-function-keys}} (キーが押されたときの挙動を変更する) |
* {{AUR|interception-hideaway}} |
* {{AUR|interception-hideaway}} |
||
* {{AUR|interception-k2k-git}} |
* {{AUR|interception-k2k-git}} |
2023年8月10日 (木) 21:44時点における版
interception-tools は、キーボード入力のマッピングの制御とカスタマイズをするためのユーティリティのセットです。
interception-tools は、libevdev と libudev(3) を使用することで、他の似たようなツール (xcape、xmodmap) よりも低レベルで動作します。ゆえに interception-tools は、X11、Wayland、そして Linux コンソール の全てでキーボードをカスタマイズできる数少ない方法の1つとなります。
目次
インストール
interception-tools をインストールしてください。
利用可能なプラグインはたくさんあります:
- interception-caps2esc (
Ctrl
/Esc
でCapsLock
を切り替える) - interception-caps2esc-delay-gitAUR
- interception-caps2esc-nocaps-gitAUR
- interception-dual-function-keys (キーが押されたときの挙動を変更する)
- interception-hideawayAUR
- interception-k2k-gitAUR
- interception-ralt2hyperAUR
- interception-space2metaAUR
- interception-uswitchAUR
- interception-vimproved-gitAUR
- interception-xswitchAUR
設定
The tools comprise commandline tools and a systemd service.
A configuration in /etc/interception/udevmon.yaml
needs to be added before starting the packaged udevmon.service
.
仕組み
Interception-tool makes use of libevdev, which according to its wiki is essentially a read(2) on steroids for /dev/input/eventX
devices.
It sits in between the kernel and the process handling an event.
In the simplest scenario would look like this:
kernel | libevdev | evtest
For X.Org input modules, the stack would look like this:
kernel | libevdev | xf86-input-evdev | X server | X client
For Wayland, the stack would look like this:
kernel | libevdev | Compositor | Wayland client
In other words, libevdev
is so low level that it does not have knowledge of X/Wayland clients.
実用例
Interception-tools makes 4 utilities available:
intercept
: redirect device input events to stdout,mux
: combine streams of input events,udevmon
: monitor input devices for launching tasks,uinput
: redirect device input events from stdin to virtual device.
実行優先度を上げる
Since the tool is going to be sitting down at the lowest level of the device inputs,
make sure it will behave consistently by increasing udevmon
priority:
# nice -n -20 udevmon -c udevmon.yaml > udevmon.log 2> udevmon.err &
シンプルなリダイレクト
The simplest way or redirecting the event to the stdin (without doing nothing) is:
$ intercept -g DEVNODE | uinput -d DEVNODE
where DEVNODE
is the path to the actual device: e.g. /dev/input/by-path/platform-i8042-serio-0-event-kbd
.
コマンドを挟む
To actually perform an operation in between the key event and the input, simply pipe it in between intercept
and uinput
.
E.g. with the interception-caps2esc plugin installed:
$ intercept -g DEVNODE | caps2esc | uinput -d DEVNODE
If we omitted the -g
flag, then device event would have been just observed, not grabbed.
YAML で設定する
This way of intercepting the input can quickly become sub-optimal, this is where udevmon
comes in handy.
udevmon accepts a YAML configuration with a list of jobs (sh commands by default) to be executed.
In case the device matches a given description:
$ udevmon -c caps2esc.conf.yml
- JOB: intercept -gDEVNODE | caps2esc | uinput -d DEVNODE DEVICE: LINK: /dev/input/by-path/platform-i8042-serio-0-event-kbd
The LINK
configuration will match a device with a specific name, but it will accept also a regex option.
This can be combined with multiple job specifications to create a default behavior, in each case only the first matching job is going to be executed:
- JOB: intercept -g DEVNODE | caps2esc -m 2 | uinput -d DEVNODE DEVICE: LINK: /dev/input/by-id/usb-SEMITEK_USB-HID_Gaming_Keyboard_SN0000000001-event-kbd - JOB: intercept -g DEVNODE | caps2esc | uinput -d DEVNODE DEVICE: EVENTS: EV_KEY: [[KEY_CAPSLOCK, KEY_ESC]] LINK: .*-event-kbd
デバイスを組み合わせる
Beside input emulation, the uinput
tool also serves purpose to print a device's description in YAML format:
$ uinput -p -d /dev/input/by-id/my-kbd
which itself can be fed back to uinput
as:
$ uinput -c my-kbd.yaml
It can also merge device and YAML characteristics, which can be used for instance to combine events coming from keyboard and mouse:
e.g. instance CapsLock+Click
as Ctrl+Click
$ uinput -p -d /dev/input/by-id/my-kbd -d /dev/input/by-id/my-mouse -c my-extra.yaml
複数のジョブを処理する
The mux
is used to combine multiple pipelines into a single one.
A muxer needs to be created first,
and it can later be used as the input or the output of a given pipeline.
In a YAML specification file, the muxer is created using the CMD
key:
- CMD: mux -c caps2esc - JOB: mux -i caps2esc | caps2esc | uinput -c /etc/interception/gaming-keyboard.yaml - JOB: intercept -g DEVNODE | mux -o caps2esc DEVICE: LINK: /dev/input/by-id/my-kbd - JOB: intercept DEVNODE | mux -o caps2esc DEVICE: LINK: /dev/input/by-id/my-mouse
In the example above, when the keyboard is connected, it's grabbed and its input events are sent to the caps2esc
muxer that was initially created. Observed input (not grabbed) from mouse is also sent to the same muxer. The buttons of the mouse generate EV_KEY
events, so caps2esc
will accept them.
参照
- 入力リマップユーティリティ - Lists similar software.
- Official website
- kmonad - advanced keyboard remapping tool daemon