Make the udev rules easier to read and manage
This commit is contained in:
parent
e905d86fc5
commit
8f47e62b36
1 changed files with 19 additions and 10 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
Check up for QMK environment.
|
Check up for QMK environment.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import platform
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -9,6 +10,13 @@ import glob
|
||||||
|
|
||||||
from milc import cli
|
from milc import cli
|
||||||
|
|
||||||
|
def _udev_rule(vid, pid = None):
|
||||||
|
""" Helper function that return udev rules
|
||||||
|
"""
|
||||||
|
if pid:
|
||||||
|
return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", ATTRS{idProduct}=="%s", MODE:="0666"' % (vid, pid)
|
||||||
|
else:
|
||||||
|
return 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="%s", MODE:="0666"' % vid
|
||||||
|
|
||||||
@cli.subcommand('Basic QMK environment checks')
|
@cli.subcommand('Basic QMK environment checks')
|
||||||
def doctor(cli):
|
def doctor(cli):
|
||||||
|
@ -18,7 +26,6 @@ def doctor(cli):
|
||||||
|
|
||||||
TODO(unclaimed):
|
TODO(unclaimed):
|
||||||
* [ ] Compile a trivial program with each compiler
|
* [ ] Compile a trivial program with each compiler
|
||||||
* [ ] Check for udev entries on linux
|
|
||||||
"""
|
"""
|
||||||
cli.log.info('QMK Doctor is checking your environment.')
|
cli.log.info('QMK Doctor is checking your environment.')
|
||||||
|
|
||||||
|
@ -50,15 +57,17 @@ def doctor(cli):
|
||||||
# Checking for udev rules
|
# Checking for udev rules
|
||||||
udev_dir = "/etc/udev/rules.d/"
|
udev_dir = "/etc/udev/rules.d/"
|
||||||
# These are the recommended udev rules
|
# These are the recommended udev rules
|
||||||
desired_rules = {"dfu": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff4", MODE:="0666"',
|
desired_rules = dict(dfu = {_udev_rule("03eb", "2ff4"),_udev_rule("03eb", "2ffb"), _udev_rule("03eb", "2ff0")},
|
||||||
'SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ffb", MODE:="0666"',
|
|
||||||
'SUBSYSTEMS=="usb", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2ff0", MODE:="0666"'},
|
tmk = {_udev_rule("feed")},
|
||||||
"tmk": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="feed", MODE:="0666"'},
|
|
||||||
"input-club": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1c11", MODE:="0666"'},
|
input_club = {_udev_rule("1c11")},
|
||||||
"stm32": {'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1eaf", ATTRS{idProduct}=="0003", MODE:="0666"',
|
|
||||||
'SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", MODE:="0666"'},
|
stm32 = {_udev_rule("1eaf", "0003"),_udev_rule("0483", "df11")},
|
||||||
"caterina": {'ATTRS{idVendor}=="2a03", ENV{ID_MM_DEVICE_IGNORE}="1"',
|
|
||||||
'ATTRS{idVendor}=="2341", ENV{ID_MM_DEVICE_IGNORE}="1"'}}
|
caterina = {'ATTRS{idVendor}=="2a03", ENV{ID_MM_DEVICE_IGNORE}="1"',
|
||||||
|
'ATTRS{idVendor}=="2341", ENV{ID_MM_DEVICE_IGNORE}="1"'}
|
||||||
|
)
|
||||||
if os.path.exists(udev_dir):
|
if os.path.exists(udev_dir):
|
||||||
udev_rules = [rule for rule in glob.iglob(os.path.join(udev_dir, "*.rules")) if os.path.isfile(rule)]
|
udev_rules = [rule for rule in glob.iglob(os.path.join(udev_dir, "*.rules")) if os.path.isfile(rule)]
|
||||||
# Collect all rules from the config files
|
# Collect all rules from the config files
|
||||||
|
|
Loading…
Reference in a new issue