#78 filtering yubikey devices

This commit is contained in:
sezanzeb 2021-04-09 20:45:56 +02:00
parent e8196f2048
commit 3bb3d09d74
2 changed files with 34 additions and 0 deletions

View File

@ -22,6 +22,7 @@
"""Device and evdev stuff that is independent from the display server."""
import re
import multiprocessing
import threading
import time
@ -168,6 +169,28 @@ def classify(device):
return UNKNOWN
DENYLIST = [
('Yubico', r'.*YubiKey.*')
]
def is_denylisted(device):
"""Check if a device should not be used in key-mapper.
Parameters
----------
device : InputDevice
"""
for vendor, name in DENYLIST:
if not re.match(vendor, str(device.info.vendor), re.IGNORECASE):
return False
if not re.match(name, str(device.name), re.IGNORECASE):
return False
return True
class _GetDevices(threading.Thread):
"""Process to get the devices that can be worked with.
@ -217,6 +240,9 @@ class _GetDevices(threading.Thread):
# skip devices that don't provide buttons that can be mapped
continue
if is_denylisted(device):
continue
name = device.name
path = device.path

View File

@ -212,6 +212,14 @@ fixtures = {
'info': evdev.device.DeviceInfo(5, 1, 5, 1),
'name': 'key-mapper device 2'
},
# denylisted
'/dev/input/event51': {
'capabilities': {evdev.ecodes.EV_KEY: keyboard_keys},
'phys': 'usb-0000:03:00.0-5/input1',
'info': evdev.device.DeviceInfo(6, 'YuBiCo', 6, 1),
'name': 'fooYuBiKeYbar'
},
}