Make a udev rule

From Lucca's Wiki
Jump to navigationJump to search

Below is an example I pulled from ns-usbloader that allows the group plugdev to access a Nintendo Switch via usb so you don't need root:


edit /etc/udev/rules.d/myAwesomeRules.rules:

SUBSYSTEM=="usb", ATTRS{idVendor}=="057e", ATTRS{idProduct}=="3000", GROUP="plugdev"


run as root: udevadm control --reload-rules && udevadm trigger



Here is a udev rule that automatically applies my keyboard prefs when I unplug and plug it back in [I use a kvm switch]:

SUBSYSTEM=="usb", ENV{DISPLAY}=":0", ATTRS{idVendor}=="1532", ATTRS{idProduct}=="008d", RUN+="/usr/bin/sudo -u lucka bash -c /home/lucka/sh/keymaps.sh"

^note that this rule uses the ids for my mouse, since the keyboard itself doesn't always seem to show as being unplugged when I kvm out and back into the computer, but the mouse does