master
parent
896040391d
commit
b91c73c5bb
|
|
@ -18,6 +18,7 @@ def up(keycode):
|
|||
_display.sync()
|
||||
|
||||
def __init_keys__():
|
||||
return [i for i in range(10, 20)] #1..0
|
||||
import subprocess
|
||||
_p = subprocess.run(
|
||||
"xmodmap -pke".split(),
|
||||
|
|
@ -26,12 +27,31 @@ def __init_keys__():
|
|||
assert(_p.returncode == 0)
|
||||
stdout = _p.stdout
|
||||
result = []
|
||||
for line in stdout.split("\n".encode()):
|
||||
allowed = ["F"+str(i) for i in range(13, 25)]
|
||||
unassigned = []
|
||||
# already assigned
|
||||
for line in stdout.split("\n".encode())[1:]:
|
||||
if line:
|
||||
words = line.split()
|
||||
key = int(words[1])
|
||||
if len(words) < 4:
|
||||
unassigned.append(key)
|
||||
elif words[3].decode() in allowed:
|
||||
allowed.remove(words[3].decode())
|
||||
result.append(key)
|
||||
# not assigned
|
||||
for key in unassigned:
|
||||
if not allowed:
|
||||
break
|
||||
word = allowed.pop()
|
||||
if word:
|
||||
assert(subprocess.run([
|
||||
"xmodmap", "-e", f"keycode {key} = {word}",
|
||||
]).returncode == 0)
|
||||
result.append(key)
|
||||
print("unassigned", unassigned)
|
||||
print("allowed", allowed)
|
||||
print("result", result)
|
||||
return result
|
||||
keys = __init_keys__()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue