Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/env python
- import openrazer.client
- import json
- # Get the keyboard device
- kbd = openrazer.client.DeviceManager().devices[0]
- # Get the total number of rows and columns,
- # and create a blank dict for the keys
- rows = kbd.fx.advanced.rows
- cols = kbd.fx.advanced.cols
- keys = {}
- # Light each key one by one and request the user
- # to input the definition for the key
- for row in range(rows):
- for col in range(1, cols):
- kbd.fx.advanced.matrix[row, col] = [255, 255, 255]
- kbd.fx.advanced.draw()
- key = input("{}, {}: ".format(row, col)).upper()
- # If we didn't get a definition, skip that row/col pair
- if key != '':
- keys[key] = [row, col]
- print(keys)
- # Write the keymap to a file as JSON
- output = json.dumps(keys)
- f = open("keymap.json", "w")
- f.write(output)
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement