Kmonad Configuration

[Witness Jo]

2024/02/16

Kmonad Configuration

kmonad is a keyboard remapping configuration tool

supporting all OS platforms (Linux, OSX, Windows)

link: https://github.com/kmonad/kmonad

Installation (AUR)

$ yay -S kmonad-bin

Configuration for as a root service (it needs root authorization)

$ sudo vi /etc/systemd/system/kmonad.service

# kmonad.service file
[Unit]
Description=laptop keyboard kmonad
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/kmonad /home/witnessjo/richard-settings/.kmonad.kbd
Restart=always
User=root
Group=root

[Install]
WantedBy=multi-user.target

Edit your kmonad configuration file

(defcfg
    ;; For Linux
  input  (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
  output (uinput-sink "My KMonad output"
                      ;; To understand the importance of the following line, see the section on
                      ;; Compose-key sequences at the near-bottom of this file.
                      "/run/current-system/sw/bin/sleep 1 && /run/current-system/sw/bin/setxkbmap -option compose:ralt")
  cmp-seq rctl    ;; Set the compose key to `RightCtrl'
  cmp-seq-delay 5 ;; 5ms delay between each compose-key sequence press

  ;; For Windows
  ;; input  (low-level-hook)
  ;; output (send-event-sink)

  ;; For MacOS
  ;; input  (iokit-name "my-keyboard-product-string")
  ;; output (kext)

  ;; Comment this if you want unhandled events not to be emitted
  fallthrough true

  ;; Set this to false to disable any command-execution in KMonad
  allow-cmd true
  )

(defsrc
    grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
    tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
    caps a    s    d    f    g    h    j    k    l    ;    '    ret
    lsft z    x    c    v    b    n    m    ,    .    /    rsft
    lctl lmet lalt           spc            ralt rmet cmp  rctl
    )

(deflayer default
    grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
    tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
    lctl a    s    d    f    g    h    j    k    l    ;    '    ret
    lsft z    x    c    v    b    n    m    ,    .    /    rsft
    caps lmet lalt           spc            rmet rmet cmp  rctl
    )

Start daemon and Make it enable

# start kmonad service
$ sudo systemctl start kmonad.service
$ sudo systemctl status kmonad.service

# enable kmonad service
$ sudo systemctl enable kmonad.service