keyremaplinux
keyremaplinux copied to clipboard
Define your keyboard layout as C++ class.
- Introduction Define your keyboard layout as C++ class. Primarily focused on implementing [[https://kozikow.wordpress.com/2013/11/15/the-only-alternative-keyboard-layout-youll-ever-need-as-a-programmer/][my keyboard layout]].
- Why use it instead of xmodmap/xcape
- Just single representation for a key to deal with - input_event code from [[https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h][input_event_codes.h]]. No need to distinguish between scancode, keysym or keycode.
- For complex layouts, xmodmap/xcape gets hard to maintain: https://github.com/kozikow/kozikow-layout-linux.
- Thread per keyboard lets you have different layout per keyboard.
- Unit test your layout.
-
Installation ** Build keyremaplinux #+BEGIN_SRC bash git clone https://github.com/kozikow/keyremaplinux ~/keyremaplinux cd ~/keyremaplinux bazel build //keyremaplinux #+END_SRC
-
Running on Linux ** Run one-of: #+BEGIN_SRC bash sudo nice -n -20 ./bazel-bin/keyremaplinux/keyremaplinux kozikow_standard #+END_SRC ** Enable automatic restarts #+BEGIN_SRC bash :results output sudo cp keyremaplinux.service /etc/systemd/system sudo systemctl enable keyremaplinux.service sudo systemctl restart keyremaplinux.service #+END_SRC
-
Implementing the new layout
- Extend [[https://github.com/kozikow/keyremaplinux/blob/master/keyremaplinux/remapper/remapper.h][Remapper]] and implement function [[https://github.com/kozikow/keyremaplinux/blob/master/keyremaplinux/remapper/remapper.h#L15][Remap]].
- For example [[https://github.com/kozikow/keyremaplinux/blob/master/keyremaplinux/remapper/kozikow_layout_remapper.h][KozikowLayoutRemapper]].
- In function Remap, consume and produce [[https://github.com/torvalds/linux/blob/master/include/uapi/linux/input.h#L25][Linux input event from input.h]]. What you consume is what user have typed. What you produce is what OS will see.
- [[https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h][Event codes are defined in input-event-codes.h]]
- Run tests #+BEGIN_SRC bash bazel test //keyremaplinux:all --test_output=errors #+END_SRC