Created
April 10, 2021 15:28
-
-
Save danryu/ee0c24ac50af40321550462bbf9ab594 to your computer and use it in GitHub Desktop.
Utility to scrape openrazer project for Razer Blade USB VID numbers for libinput quirk configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import requests | |
modelpattern = re.compile("RazerBlade\w+") | |
vidpattern = re.compile("0x\w+") | |
content = requests.get("https://raw.githubusercontent.com/openrazer/openrazer/master/daemon/openrazer_daemon/hardware/keyboards.py") | |
razerdata=[] | |
for line in content.iter_lines(decode_unicode=True): | |
razerdata.append(line) | |
for i, line in enumerate(razerdata): | |
for modelmatch in re.finditer(modelpattern, line): | |
razer_model = modelmatch.group() | |
for vidmatch in re.finditer(vidpattern, razerdata[i+7]): | |
usb_vid = vidmatch.group() | |
print("[{0} Keyboard]".format(razer_model)) | |
print("MatchUdevType=keyboard") | |
print("MatchBus=usb") | |
print("MatchVendor=0x1532") | |
print("MatchProduct={0}".format(usb_vid)) | |
print("AttrKeyboardIntegration=internal") | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment