A Fusuma plugin for remapping keyboard events into virtual input devices. Compatible with other Fusuma plugins.
THIS PLUGIN IS EXPERIMENTAL.
This plugin empowers users to manipulate keyboard events and convert them into virtual input devices. It is designed to integrate seamlessly with other Fusuma plugins, thus enabling users to construct sophisticated input configurations and achieve distinctive functionalities. A key feature is the dynamic alteration of remapping layers within the Fusuma process, thereby enabling users to adapt their keyboard inputs to suit specific tasks or applications.
This plugin requires fusuma 2.0
NOTE: If you have installed ruby by apt, you must install ruby-dev.
$ sudo apt-get install libevdev-dev ruby-dev build-essentialfusuma-plugin-remap create virtual input device(fusuma_virtual_keyboard) by uinput. So you need to set up udev rules.
$ echo 'KERNEL=="uinput", MODE="0660", GROUP="input", OPTIONS+="static_node=uinput"' | sudo tee /etc/udev/rules.d/60-udev-fusuma-remap.rulesThen, reload udev rules.
$ sudo udevadm control --reload-rules && sudo udevadm trigger$ sudo gem install fusuma-plugin-remapYou can remap keys in ~/.config/fusuma/config.yml. The remap section defines key remappings.
Simple key-to-key remapping without any context:
remap:
CAPSLOCK: LEFTCTRL
LEFTALT: LEFTMETA
LEFTMETA: LEFTALTWhen a simple key remap is defined (e.g., CAPSLOCK: LEFTCTRL), the key acts as an alias for the target modifier. The modifier state tracks the remapped key, not the physical key.
remap:
CAPSLOCK: LEFTCTRL # CAPSLOCK acts as LEFTCTRL alias
LEFTCTRL+LEFTSHIFT+J: LEFTMETA+LEFTCTRL+DOWN # Combination using the aliasWith this configuration:
- Physical
CAPSLOCKis treated asLEFTCTRL - Physical
CAPSLOCK+LEFTSHIFT+JtriggersLEFTCTRL+LEFTSHIFT+Jcombination - This outputs
LEFTMETA+LEFTCTRL+DOWN
You can send multiple key combinations in sequence using an array:
remap:
LEFTCTRL+U: [LEFTSHIFT+HOME, DELETE] # Select to line start, then delete
LEFTCTRL+K: [LEFTSHIFT+END, DELETE] # Select to line end, then deleteRemap modifier key combinations to other keys or combinations:
remap:
LEFTCTRL+J: DOWN
LEFTCTRL+K: UP
LEFTCTRL+H: LEFT
LEFTCTRL+L: RIGHT
LEFTALT+N: LEFTCTRL+TAB # Next tab
LEFTALT+P: LEFTCTRL+LEFTSHIFT+TAB # Previous tabYou can define different remappings for different contexts. Contexts are separated by ---.
Remap keys only for specific applications:
---
context:
application: Alacritty
remap:
LEFTMETA+N: LEFTCTRL+LEFTSHIFT+T # New tab in terminal
LEFTMETA+W: LEFTCTRL+LEFTSHIFT+W # Close tabFor thumbsense mode, install fusuma-plugin-thumbsense:
---
context:
thumbsense: true
remap:
J: BTN_LEFT
K: BTN_RIGHT
F: BTN_LEFT
D: BTN_RIGHT
SPACE: BTN_LEFTYou can define different remappings for specific keyboard devices. The device pattern uses case-insensitive partial matching against the physical device name.
---
# HHKB-specific remappings (matches device names containing "HHKB")
context:
device: HHKB
remap:
LEFTCTRL: LEFTMETA # Swap Ctrl to Meta on HHKB
---
# Built-in keyboard remappings (matches "AT Translated Set 2 keyboard")
context:
device: AT Translated
remap:
LEFTALT: LEFTCTRL # Remap Alt to Ctrl on built-in keyboardTo find your keyboard's device name, run:
libinput list-devicesYou can combine multiple context conditions. When multiple contexts are active, mappings are merged with priority order: device < thumbsense < application.
---
# HHKB + Thumbsense mode
context:
device: HHKB
thumbsense: true
remap:
J: BTN_LEFT
K: BTN_RIGHT# Default remappings (always active)
remap:
CAPSLOCK: LEFTCTRL
LEFTALT: LEFTMETA
LEFTMETA: LEFTALT
LEFTCTRL+J: DOWN
LEFTCTRL+K: UP
---
# Application-specific remappings
context:
application: Alacritty
remap:
LEFTMETA+N: LEFTCTRL+LEFTSHIFT+T
---
# Thumbsense mode
context:
thumbsense: true
remap:
J: BTN_LEFT
K: BTN_RIGHTThis plugin includes a special keybind for emergency stop. Pressing this key combination will ungrab the physical keyboard and terminate the Fusuma process. This feature is particularly useful in situations where the plugin or system becomes unresponsive.
To execute the emergency stop, press the following key combination(default):
- RIGHTCTRL → LEFTCTRL
You can configure the emergency stop key in your Fusuma configuration file (~/.config/fusuma/config.yml) as follows:
plugin:
inputs:
remap_keyboard_input:
emergency_ungrab_keys: RIGHTCTRL+LEFTCTRL # <- Set two keys separated by '+' to trigger the emergency stopThis configuration allows you to specify which keys will trigger the emergency stop functionality. It is important to verify this keybind to ensure a swift response during unexpected situations.
configure plugin.inputs.remap_keyboard_input in ~/.config/fusuma/config.yml to specify which physical keyboard to remap.
If your external or built-in keyboard is not detected, run libinput list-devices to find its name and add a matching pattern under keyboard_name_patterns.
plugin:
inputs:
remap_keyboard_input:
# By default, Fusuma will detect physical keyboards matching these patterns.
# You can specify multiple regular‐expression strings in an array.
keyboard_name_patterns:
# Default value
- keyboard|Keyboard|KEYBOARD
# Emergency stop key combination.
# Specify exactly two keys joined by '+'.
emergency_ungrab_keys: RIGHTCTRL+LEFTCTRLYou can customize keyboard_name_patterns like this:
plugin:
inputs:
remap_keyboard_input:
keyboard_name_patterns:
- xremap # Virtual keyboard created by another remapper
- PFU Limited HHKB-Hybrid # External keyboard
- keyboard|Keyboard|KEYBOARD # Default patternIf your keyboard isn’t detected, run:
libinput list-devicesand add a suitable name pattern.
To specify touchpad name, configure plugin.inputs.remap_touchpad_input:
plugin:
inputs:
remap_touchpad_input:
# By default, Fusuma will detect physical touchpads matching these patterns.
touchpad_name_patterns:
# Default values
- touchpad|Touchpad|TOUCHPAD
- trackpad|Trackpad|TRACKPADYou can customize touchpad_name_patterns like this:
plugin:
inputs:
remap_touchpad_input:
touchpad_name_patterns:
- Apple Inc. Magic Trackpad # External Trackpad
- your touchpad device name # Any other touchpad
- Touchpad|Trackpad # match to "Touchpad" or "Trackpad"Bug reports and pull requests are welcome on GitHub at https://github.com/iberianpig/fusuma-plugin-remap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Fusuma::Plugin::Remap project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.