Skip to content

Instantly share code, notes, and snippets.

@mcardillo55
Created May 11, 2017 09:30
Show Gist options
  • Select an option

  • Save mcardillo55/ffbe7ce33c273d611d67b0fd83eb2ca3 to your computer and use it in GitHub Desktop.

Select an option

Save mcardillo55/ffbe7ce33c273d611d67b0fd83eb2ca3 to your computer and use it in GitHub Desktop.
Control speed of the Razer 'wave' effect by sending custom values to the razerkbd driver and varying the sleep() time
# Author: Mike Cardillo, 2017
# Email: [email protected]
# Desc: Control speed of the Razer 'wave' effect by sending custom values to
# the razerkbd driver and varying the sleep() time.
import pyshark
import time
import os, sys
RAZERKBD_SYSFS_PATH = '/sys/bus/hid/drivers/razerkbd/0003:1532:0221.0013/'
PCAP_FILE = '/home/mike/razer_packets.pcapng'
cap = pyshark.FileCapture(PCAP_FILE)
slow_wave_pattern = []
for idx, cur_cap in enumerate(cap):
if idx == 966:
# This is when the pattern repeats.
break
cap_data = cur_cap.data.usb_data_fragment
if cap_data.binary_value[8] == 255:
# First 8 bytes are control bytes and not included
# Next are row index, row start and row stop
# Then 22 RGB values
slow_wave_pattern.append(cap_data.binary_value[9:78])
print("done analyzing")
print(len(slow_wave_pattern))
while True:
for pattern in slow_wave_pattern:
if pattern[0] == 0:
with open(os.path.join(RAZERKBD_SYSFS_PATH, 'matrix_effect_custom'), 'w') as enable_custom_effect:
enable_custom_effect.write('1')
with open(os.path.join(RAZERKBD_SYSFS_PATH, 'matrix_custom_frame'), 'wb') as custom_frame:
custom_frame.write(pattern)
sys.stdout.flush()
time.sleep(0.0010)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment