Files
UsbMakroBoard/README.md
2024-05-06 20:38:43 +02:00

2.2 KiB

UsbMakroBoard

Cudos

For info that with "EVIOCGRAB" the keyboard events can be consumed exclusively by one application: https://stackoverflow.com/questions/29942421/read-barcodes-from-input-event-linux-c/29956584#29956584

Arguments

-c <path to config>

Configuration

The configuration can be

Allowing non-root access to the device

By default, accessing input devices requires root privileges. However, it's possible to allow a regular user to access a specific input device by creating a udev rule:

  1. Identify the device's vendor and product IDs. You can do this by running lsusb in the terminal and looking for your device. This may looke like this where 195d is the vendor_id and 6008 is the product_id:

    # lsusb
    Bus 003 Device 005: ID 195d:6008 Itron Technology iONE Falcon 20 RGB
    
  2. Create a new udev rule. Open a new file in the /etc/udev/rules.d/ directory. The filename should end with .rules, for example 90-input.rules (the number determins the order in which the rules are loaded. It is generally recommended to chose higher numbers for changes that are relevant for the user-space).

    In the new file, write a rule that matches your device and sets the mode to 0666 (read and write permissions for everyone). Replace vendor_id and product_id with your device's IDs from the first step.

    SUBSYSTEM=="input", ATTRS{idVendor}=="vendor_id", ATTRS{idProduct}=="product_id", MODE="0666"
    
  3. Reload the udev rules with the command sudo udevadm control --reload-rules && sudo udevadm trigger.

Now, every time the device is connected, it will be accessible by all users. The rule can be made more specific to only make the device accessible to a certain user or user group. You can use the OWNER, GROUP, and MODE parameters in the udev rule. For example, to restrict access to the user username and the group usergroup, you can use:

SUBSYSTEM=="input", ATTRS{idVendor}=="vendor_id", ATTRS{idProduct}=="product_id", OWNER="username", GROUP="usergroup", MODE="0660"

This will give read and write permissions to the user and/or the group, and no permissions to others.