sudo groupadd uinput
sudo usermod -aG input,uinput username
 

To set up the udev rule for KMonad, you need to create a new udev rule file in the /etc/udev/rules.d/ directory. The file should follow the naming convention XX-<name>.rules, where XX is a two-digit number that determines the order in which the rules are applied, and <name> is a short identifier for the rule. The file name should reflect its purpose, so you might choose something like 99-kmonad-uinput.rules for clarity.

Here’s a step-by-step guide to create the udev rule file:

  1. Open a terminal.

  2. Use a text editor with root privileges to create and edit the file. For example, you can use nano:

    sudo nano /etc/udev/rules.d/99-kmonad-uinput.rules
  3. In the text editor, add the following line:

    KERNEL=="uinput", MODE="0660", GROUP="uinput", OPTIONS+="static_node=uinput"
  4. Save the file and exit the text editor. If you’re using nano, you can do this by pressing Ctrl+X, then Y to confirm saving changes, and finally Enter to confirm the file name.

  5. Reload the udev rules to apply the changes:

    sudo udevadm control --reload-rules
    sudo udevadm trigger

After these steps, the udev rule should be in place, and KMonad should have the necessary permissions to access the /dev/uinput device file [0][2].

sudo modprobe uinput
 
[Unit]
Description=kmonad keyboard config

[Service]
Restart=always
RestartSec=3
ExecStart=/usr/bin/kmonad %E/kmonad/%i.kbd
Nice=-20

[Install]
DefaultInstance=config
WantedBy=default.target

To ensure that your systemd service file is properly located and recognized by systemd, you should place it in the appropriate directory for user-specific units. For user-specific systemd units, you typically place them in the following directory:

~/.config/systemd/user/

So, your systemd service file should be placed in:

~/.config/systemd/user/kmonad.service

Make sure to name the file kmonad.service, as that’s what systemd will use to identify the service. After placing the file there, you can enable and start the service using systemctl --user commands.

Here’s how you can do it:

  1. Place the service file in ~/.config/systemd/user/kmonad.service.
  2. Reload systemd to pick up the new service: systemctl --user daemon-reload.
  3. Enable the service: systemctl --user enable kmonad.service.
  4. Start the service: systemctl --user start kmonad.service.

Ensure that your executable /usr/bin/kmonad and the keyboard configuration files %E/kmonad/%i.kbd are set up correctly and accessible as well.