Package: wayremap
wayremapDynamic keyboard remapper for Wayland.It works on both X Window Manager and Wayland, but focused on Wayland as it intercepts evdev input and require root permission.MotivationWayland and Sway is awesome. It brings lots of benefit to Linux desktop environment.When I was using X desktop envionment, there is an awesome tool calledxremapwhich remap keysbased on current focused application.https://github.com/k0kubun/xremapI was looking for something similar toxremapfor Wayland, but not found, so I decided to create on my own.Installsudopipinstallwayremap# For beta versionsudopip3installgit+https://github.com/acro5piano/wayremapRunFor Wayland security model, we have to run keyboard remapping tools as root permission.Simply write your own service and run it as a python script:# /etc/wayremap.config.pyfromwayremapimportecodesase,run,WayremapConfig,Binding,wait_swayimportuinputaskwayremap_config=WayremapConfig(# Note that `'/dev/input/event4'` varies among system.input_path='/dev/input/event4',# Filter applications which remap will be appliedapplications=['Chromium','Brave-browser','Leafpad','firefoxdeveloperedition',],bindings=[# To see all available binding keys, please see# https://github.com/acro5piano/wayremap/blob/06d27c9bb86b766d7fd1e4230f3a16827785519e/wayremap/ecodes.py# modifier keys are `KEY_LEFTCTRL` or `KEY_LEFTALT`, or both. Neither `shift` nor `super` is not implemented yet.# Emacs-like key bindingBinding([e.KEY_LEFTCTRL,e.KEY_LEFTALT,e.KEY_A],[[k.KEY_LEFTCTRL,k.KEY_HOME]]),Binding([e.KEY_LEFTCTRL,e.KEY_LEFTALT,e.KEY_E],[[k.KEY_LEFTCTRL,k.KEY_END]]),Binding([e.KEY_LEFTCTRL,e.KEY_LEFTALT,e.KEY_H],[[k.KEY_LEFTCTRL,k.KEY_BACKSPACE]]),Binding([e.KEY_LEFTCTRL,e.KEY_F],[[k.KEY_RIGHT]]),Binding([e.KEY_LEFTCTRL,e.KEY_B],[[k.KEY_LEFT]]),Binding([e.KEY_LEFTCTRL,e.KEY_P],[[k.KEY_UP]]),Binding([e.KEY_LEFTCTRL,e.KEY_N],[[k.KEY_DOWN]]),Binding([e.KEY_LEFTCTRL,e.KEY_K],[[k.KEY_LEFTSHIFT,k.KEY_END],[k.KEY_LEFTCTRL,k.KEY_X]]),Binding([e.KEY_LEFTCTRL,e.KEY_A],[[k.KEY_HOME]]),Binding([e.KEY_LEFTCTRL,e.KEY_E],[[k.KEY_END]]),Binding([e.KEY_LEFTCTRL,e.KEY_Y],[[k.KEY_LEFTCTRL,k.KEY_V]]),Binding([e.KEY_LEFTALT,e.KEY_F],[[k.KEY_LEFTCTRL,k.KEY_RIGHT]]),Binding([e.KEY_LEFTALT,e.KEY_B],[[k.KEY_LEFTCTRL,k.KEY_LEFT]]),Binding([e.KEY_LEFTALT,e.KEY_D],[[k.KEY_LEFTCTRL,k.KEY_DELETE]]),Binding([e.KEY_LEFTCTRL,e.KEY_H],[[k.KEY_BACKSPACE]]),Binding([e.KEY_LEFTCTRL,e.KEY_D],[[k.KEY_DELETE]]),Binding([e.KEY_LEFTCTRL,e.KEY_S],[[k.KEY_LEFTCTRL,k.KEY_F]]),# OSX-like key bindingBinding([e.KEY_LEFTALT,e.KEY_A],[[k.KEY_LEFTCTRL,k.KEY_A]]),Binding([e.KEY_LEFTALT,e.KEY_C],[[k.KEY_LEFTCTRL,k.KEY_C]]),Binding([e.KEY_LEFTALT,e.KEY_V],[[k.KEY_LEFTCTRL,k.KEY_V]]),# Slack helm!Binding([e.KEY_LEFTALT,e.KEY_X],[[k.KEY_LEFTCTRL,k.KEY_K]]),])# Required if you want to use wayremap as a startup service.wait_sway()# Finally, run wayremap.run(wayremap_config)And thensudo modprobe uinput
sudo python /opt/wayremap.pyEnable wayremap as a systemd serviceechouinput|sudotee/etc/modules-load.d/wayremap.conf# Add uinput to auto-loaded linux modulessudovim/etc/wayremap.config.py# Edit your configsudocp./systemd/wayremap.service/etc/systemd/system/wayremap.service
sudosystemctlenablewayremap
sudorebootKnown bugs3is pressed when changing focused window→ Fixed nowKey repeating become slow while switching focused windowdRoadmapEnable to run wihtout Sway.Supportshiftandsuperkeys too.Packaging for Arch Linux, Debian, Fedora, etc.Enable to load per-application config.Re-write in Rust for better performance.