-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathxkeysnail.py
More file actions
executable file
·129 lines (120 loc) · 4.42 KB
/
xkeysnail.py
File metadata and controls
executable file
·129 lines (120 loc) · 4.42 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- coding: utf-8 -*-
import re
from xkeysnail.transform import *
# define timeout for multipurpose_modmap
define_timeout(0.4)
# # [Multipurpose modmap] Give a key two meanings. A normal key when pressed and
# # released, and a modifier key when held down with another key. See Xcape,
# # Carabiner and caps2esc for ideas and concept.
define_multipurpose_modmap(
{
Key.LEFT_CTRL: [Key.ESC, Key.LEFT_CTRL],
Key.RIGHT_SHIFT: [Key.ENTER, Key.RIGHT_SHIFT],
Key.HENKAN: [Key.BACKSPACE, Key.HENKAN],
Key.RIGHT_ALT: [Key.RIGHT_ALT, Key.RIGHT_ALT], # Customized in transform.py
}
)
# define_conditional_multipurpose_modmap(re.compile("discord|TelegramDesktop|Wine"),
# {Key.LEFT_CTRL: [Key.ESC, Key.LEFT_CTRL],
# Key.RIGHT_SHIFT: [Key.ENTER, Key.RIGHT_SHIFT]}
# )
# # [Conditional multipurpose modmap] Multipurpose modmap in certain conditions,
# # such as for a particular device.
# define_conditional_multipurpose_modmap(lambda wm_class, device_name: device_name.startswith("Microsoft"), {
# # Left shift is open paren when pressed and released.
# # Left shift when held down.
# Key.LEFT_SHIFT: [Key.KPLEFTPAREN, Key.LEFT_SHIFT],
# # Right shift is close paren when pressed and released.
# # Right shift when held down.
# Key.RIGHT_SHIFT: [Key.KPRIGHTPAREN, Key.RIGHT_SHIFT]
# })
# Emacs-like keybindings in non-Emacs applications
define_keymap(
re.compile("discord"),
{
# Cursor
K("C-b"): with_mark(K("left")),
K("C-f"): with_mark(K("right")),
K("C-k"): with_mark(K("up")),
K("C-j"): with_mark(K("down")),
K("C-h"): with_mark(K("backspace")),
K("LM-b"): with_mark(K("RC-left")),
K("LM-f"): with_mark(K("RC-right")),
K("C-a"): with_mark(K("home")),
K("C-e"): with_mark(K("end")),
K("LM-v"): with_mark(K("page_up")),
K("C-v"): with_mark(K("page_down")),
K("C-o"): [K("LShift-end"), K("delete"), set_mark(False)],
K("C-u"): [K("LShift-home"), K("backspace"), set_mark(False)],
K("C-i"): K("tab"),
K("C-d"): [K("delete"), set_mark(False)],
K("LM-d"): [K("RC-delete"), set_mark(False)],
K("C-space"): set_mark(True),
K("C-g"): [K("esc"), set_mark(False)],
K("LM-backspace"): K("RC-backspace"),
K("LM-d"): K("RC-delete"),
K("C-comma"): K("RM-up"),
K("C-dot"): K("RM-down"),
K("LM-comma"): K("RC-RM-up"),
K("LM-dot"): K("RC-RM-down"),
K("C-s"): [K("RC-f"), set_mark(False)],
K("LM-j"): [K("end"), K("Shift-slash"), K("enter"), set_mark(False)],
K("LM-Shift-key_5"): K("RC-h"),
K("C-key_2"): K("RC-i"),
K("LM-g"): K("RC-k"),
},
"Discord Emacs-like keys",
)
# Emacs-like keybindings in non-Emacs applications
define_keymap(
re.compile("TelegramDesktop"),
{
# Cursor
K("C-b"): with_mark(K("left")),
K("C-f"): with_mark(K("right")),
K("C-k"): with_mark(K("up")),
K("C-j"): with_mark(K("down")),
K("C-h"): with_mark(K("backspace")),
K("LM-b"): with_mark(K("RC-left")),
K("LM-f"): with_mark(K("RC-right")),
K("C-a"): with_mark(K("home")),
K("C-e"): with_mark(K("end")),
K("LM-v"): with_mark(K("page_up")),
K("C-v"): with_mark(K("page_down")),
K("C-o"): [K("LShift-end"), K("delete"), set_mark(False)],
K("C-u"): [K("LShift-home"), K("backspace"), set_mark(False)],
K("C-i"): K("tab"),
K("C-d"): [K("delete"), set_mark(False)],
K("LM-d"): [K("RC-delete"), set_mark(False)],
K("LM-backspace"): K("RC-backspace"),
K("LC-key_9"): K("RC-page_up"),
K("LC-key_0"): K("RC-page_down"),
K("LM-o"): K("RC-o"),
K("C-s"): [K("RC-f"), set_mark(False)],
K("LM-j"): [K("end"), K("LShift-slash"), K("enter"), set_mark(False)],
},
"Telegram Emacs-like keys",
)
# Emacs-like keybindings in non-Emacs applications
define_keymap(
re.compile("Vivaldi-stable"),
{
# Cursor
K("C-k"): with_mark(K("up")),
K("C-j"): with_mark(K("down")),
K("C-LM-a"): K("LM-d"),
K("C-key_0"): K("LM-F12"),
K("C-key_9"): K("LM-F11"),
},
"Vivaldi Emacs-like keys",
)
# Emacs-like keybindings in non-Emacs applications
define_keymap(
re.compile("copyq"),
{
K("C-k"): K("up"),
K("C-j"): K("down"),
K("C-d"): K("delete"),
},
"copyq Emacs-like keys",
)