Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #!/bin/env python
  2.  
  3. import openrazer.client
  4. import json
  5.  
  6. # Get the keyboard device
  7. kbd = openrazer.client.DeviceManager().devices[0]
  8.  
  9. # Get the total number of rows and columns,
  10. # and create a blank dict for the keys
  11. rows = kbd.fx.advanced.rows
  12. cols = kbd.fx.advanced.cols
  13. keys = {}
  14.  
  15. # Light each key one by one and request the user
  16. # to input the definition for the key
  17. for row in range(rows):
  18.   for col in range(1, cols):
  19.     kbd.fx.advanced.matrix[row, col] = [255, 255, 255]
  20.     kbd.fx.advanced.draw()
  21.     key = input("{}, {}: ".format(row, col)).upper()
  22.  
  23.     # If we didn't get a definition, skip that row/col pair
  24.     if key != '':
  25.       keys[key] = [row, col]
  26.  
  27. print(keys)
  28.  
  29. # Write the keymap to a file as JSON
  30. output = json.dumps(keys)
  31. f = open("keymap.json", "w")
  32. f.write(output)
  33. f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement