-
Notifications
You must be signed in to change notification settings - Fork 0
/
_global.py
60 lines (41 loc) · 1.4 KB
/
_global.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from subprocess import Popen, PIPE
import natlink
from dragonfly import (Grammar, AppContext, MappingRule, Dictation,
Key, Text, FocusWindow, Function, Mimic,
StartApp, IntegerRef)
grammar = Grammar("global")
def snore(**kw):
natlink.setMicState('sleeping')
example_rule = MappingRule(
name="global",
mapping={
'scratch': Mimic('scratch', 'that'),
'Pick <n>': Key('down/5:%(n)d, enter'),
'Pick Minus <n>': Key('up/5:%(n)d, enter'),
'swap': Key('w-tab/5'),
'<n> swap': Key('w-tab/5:%(n)d'),
'swap <text>': FocusWindow(title='%(text)s'),
'win left': Key('w-left'),
'win right': Key('w-right'),
'desk <n>': Key('w-%(n)d'),
'snore': Function(snore),
'Show task [manager]': Key('cs-escape'),
#
# Words and phrases
'import clarus': Text('import brighttrac2 as clarus'),
},
extras=[
Dictation("text"),
IntegerRef("n", 1, 100),
],
)
# Add the action rule to the grammar instance.
grammar.add_rule(example_rule)
#---------------------------------------------------------------------------
# Load the grammar instance and define how to unload it.
grammar.load()
# Unload function which will be called by natlink at unload time.
def unload():
global grammar
if grammar: grammar.unload()
grammar = None