Programming My QMK Keyboard In Linux
My daily driver keyboard is a Keychron Q60 Max that I just adore. To change settings, I use Keychron's Launcher (which appears to be a forked version of Via) in Ungoogled Chromium via flatpak.
In order to successfully connect to the keyboard, I need to have read/write access to it. Here's how to set this up in a relatively strict and sane way using udev.
Pick a group to own the device
Some people choose users
, but I picked plugdev
. Funny enough, my default user in Pop!_OS was a member of plugdev
by default, but not a member of users
. 🤷
Make sure your user is a member of the group you pick.
jaysherby@framework13:~$ groups
jaysherby adm sudo plugdev lpadmin
Find the device's vendor id and product id
jaysherby@framework13:~$ lsusb
# ...snip...
Bus 003 Device 015: ID 3434:08c0 Keychron Keychron Q60 Max
# ...snip...
My keyboard's vendor id is 3434 and its product id is 08c0.
Add a udev rule
I named my udev rule /etc/udev/rules.d/92-keychron-q60-max.rules
. I know the number at the beginning determines the order in which rules are processed relative to each other. This is my only current custom udev rule. The number 92 was cargo culted in from the internet.
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="3434", ATTRS{idProduct}=="08c0", MODE="0660", GROUP="plugdev", TAG+="uaccess", TAG+="udev-acl"
Notice the usage of the vendor and product ids and the name of the group. The tags are also cargo culted and may not be strictly necessary.
Reload the udev rules
To reload the udev rules without having to restart the computer, run the following command.
sudo udevadm control --reload-rules && sudo udevadm trigger
You can make sure the rules applied correctly by checking the permissions and ownership of the /dev/hidraw*
devices.
jaysherby@framework13:~$ ls -lah /dev/hidraw*
crw------- 1 root root 241, 0 Feb 26 22:24 /dev/hidraw0
crw------- 1 root root 241, 1 Feb 26 22:24 /dev/hidraw1
crw------- 1 root root 241, 2 Feb 26 22:24 /dev/hidraw2
crw-rw---- 1 root plugdev 241, 3 Feb 26 22:31 /dev/hidraw3
crw-rw---- 1 root plugdev 241, 4 Feb 26 22:31 /dev/hidraw4
crw-rw---- 1 root plugdev 241, 5 Feb 26 22:31 /dev/hidraw5
crw-rw----+ 1 root root 241, 6 Feb 26 22:24 /dev/hidraw6
crw------- 1 root root 241, 7 Feb 26 22:24 /dev/hidraw7
Devices 3, 4, and 5 are owned by the plugdev
group with read/write access.
If something goes wrong, it's worth trying to connect to the keyboard using Keychron's Launcher and then checking chrome://device-log/ for any clues or interesting messages.