File: keymaptest.py

package info (click to toggle)
ckb-next 0.6.2%2Bdfsg-0.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,744 kB
  • sloc: cpp: 20,009; ansic: 13,562; xml: 434; sh: 222; python: 74; makefile: 12
file content (40 lines) | stat: -rwxr-xr-x 874 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import re
import os
import signal
import subprocess
import time

keymaps = []
with open("src/daemon/usb.c", "r") as f:
    for l in f:
        if m := re.search(r'        return "(.*)";', l):
            mg = m.group(1)
            if mg != "corsair":
                keymaps.append(mg)

ckb = "./build/bin/ckb-next"
daemon = "/dev/input/ckb1/features"
subprocess.run([ckb, "-c"])

for km in keymaps:
    print("Now testing " + km)
    f = open(daemon, "r")
    features = f.read().split()
    f.close()
    
    features[1] = km

    while True:
        try:
            f = open(daemon, "w")
            break
        except OSError:
            input(f"Error opening {daemon} for writing. Press enter to try again")
    f.write(" ".join(features))
    f.close()

    subprocess.run([ckb])
    print("Quit ckb-next to continue")

print("Finished!")