-
Notifications
You must be signed in to change notification settings - Fork 1
/
layout2.py
executable file
·41 lines (34 loc) · 1.18 KB
/
layout2.py
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
41
#!/usr/bin/env python3
# Copyright © 2019 Axel Svensson <mail@axelsvensson.com>
# This file is part of keyboa version <VERSION>
# Legal: See COPYING.txt
# This is a minimal example of how to use libkeyboa. It switches Left Control
# and Caps Lock.
#
# Run in cmd:
# listenkey -ces | python3 layout2.py | sendkey
#
# Or in cygwin:
# ./listenkey -ces | ./layout2.py | ./sendkey
from libkeyboa import *
mapping={
"VK_CAPITAL": "VK_LCONTROL",
"VK_LCONTROL": "VK_CAPITAL",
}
@retgen
def remap(gen):
for obj in gen:
if(obj["type"] in ["keydown", "keyup", "keypress"]):
vks=obj["win_virtualkey_symbol"]
if(vks in mapping):
yield {"type": obj["type"], **data.vkeyinfo(mapping[vks])}
continue
yield obj
list_of_transformations = [
tr.input_events(), # libkeyboa
tr.altgr_workaround_input(), # libkeyboa
tr.enrich_input(), # libkeyboa
remap(), # layout2
tr.altgr_workaround_output(), # libkeyboa
tr.output_events()] # libkeyboa
keyboa_run(list_of_transformations)