Package: waylandmap
WaylandMapI started to code this program because I want to use RightAlt + hjkl as system-wide arrow keys. Everyone has been usingxmodmapto remap keys on linux. However, after switching to Wayland window system,xmodmapstopped working. I started to look for ready-to-use solution but with no luck. Probably Wayland are still too new for the community to catch up. Luckly, Google gave me some hints on how to achieve this task. The key is to go to lower level! This module makes use ofevdevanduinputmodule to achieve keymapping. Therefore it should work on any Desktop, such as X11 or Wayland.InstallSimply install usingpipand run it as a cli application:pip install waylandmapIt is recommended to install the package to its own virtual environment, especially when installed as a linux system service. For example, install usingpipx:pipx install waylandmapUsageYour can run the keymapper directly by supplying the name of keyboard and the keymap file.sudowaylandmap-n<name-of-your-keyboard><path/to/config.yml>You can see the key event inputs and outputs printed out in real time by running in debug mode. You can also check the string name required by the config file.sudowaylandmap--debug-n<name-of-your-keyboard><path/to/config.yml>ConfigurationThe program accept a config file path as argument. The config file should be in yaml format.# keymaps.yaml# map one single key with another-type:mapsource:KEY_LEFTALTtarget:KEY_LEFTCTRL-type:mapsource:KEY_LEFTMETAtarget:KEY_LEFTALT-type:mapsource:KEY_LEFTCTRLtarget:KEY_LEFTMETA# simply swap two single key-type:swaptarget1:KEY_CAPSLOCKtarget2:KEY_ESC# map 2-keys-chord into a new key# # RightAlt + hjkl to arrows-type:combomodifier:KEY_RIGHTALTsource:KEY_Htarget:KEY_LEFT-type:combomodifier:KEY_RIGHTALTsource:KEY_Jtarget:KEY_DOWN-type:combomodifier:KEY_RIGHTALTsource:KEY_Ktarget:KEY_UP-type:combomodifier:KEY_RIGHTALTsource:KEY_Ltarget:KEY_RIGHT# # remap home + pgdn + pgup + end-type:combomodifier:KEY_RIGHTALTsource:KEY_Ntarget:KEY_HOME-type:combomodifier:KEY_RIGHTALTsource:KEY_Mtarget:KEY_PAGEDOWN-type:combomodifier:KEY_RIGHTALTsource:KEY_COMMAtarget:KEY_PAGEUP-type:combomodifier:KEY_RIGHTALTsource:KEY_DOTtarget:KEY_END# # remap backspace + delete-type:combomodifier:KEY_RIGHTALTsource:KEY_Ytarget:KEY_BACKSPACE-type:combomodifier:KEY_RIGHTALTsource:KEY_Utarget:KEY_BACKSPACE-type:combomodifier:KEY_RIGHTALTsource:KEY_Itarget:KEY_DELETE-type:combomodifier:KEY_RIGHTALTsource:KEY_Otarget:KEY_DELETE# more key combo options is comingInstall as Linux system servicesAfter writing your config file and test running it without problem, your can install the program as a system services. This should automatically start the keymapper everytime when you login. You may usesystemctl/waylandmap.serviceas a template to edit the services file, and then install the service as follows:sudo cp systemctl/waylandmap.service /etc/systemd/system/
sudo systemctl enable waylandmap.serviceWarningDue to the design of the program, once a modifier key has been registered as part of a combo, its events will no longer visible to the O.S. Essentially, this modifier key is disabled system-wide. By default, the program will first handlemap, thenswap, and finally thecombo. No remapping is done in any rules, therefore, if there are multiple rules applicable to the same key, only the first matched rule will be handled.