class Python (dragonfly.MappingRule): mapping = python_mapping extras = [ Dictation('text'), Dictation('text2'), IntegerRef('n', 1, 999), IntegerRef('n2', 1, 999), ]
class Basics(dragonfly.MappingRule): mapping = basics_mapping extras = [ Dictation('text'), IntegerRef('n', 1, 999), IntegerRef('n2', 1, 999), Choice("pressKey", pressKeyMap), Choice("surroundChar", surroundCharsMap), ]
def __init__(self, *args, **kwargs): self.mapping = { _('open terminal'): Key('w-t'), _('workspace <n>'): Function(go_to_workspace), _('move [to] workspace <n>'): Function(move_to_workspace), _('window <direction>'): Key('w-%(direction)s'), _('move window [to the] <direction>'): Key('sw-%(direction)s'), _("fullscreen"): Key("w-f"), _("tabbed layout"): Key("w-w"), _("tiling layout"): Key("w-e"), _("stacking layout"): Key("w-s"), _("kill focused window"): Key("ws-q"), _("horizontal split"): Key("w-h"), _("vertical split"): Key("w-v"), _("toggle floating"): Key("ws-space"), _("focus floating"): Key("w-space"), _("reload i3 config file"): Key("ws-c"), _("restart i3 in place"): Key("ws-r"), _("I'm really sure I want to exit i3"): Key("ws-e"), _("resize mode"): Key("w-r"), _("invert screen rotation"): Key("ws-a"), _("reset screen rotation"): Key("ws-n"), _("(display|show) window info"): Key("ws-t"), } self.extras = [ IntegerRef('n', 1, 13), Choice( 'direction', { _('left'): 'left', _('right'): 'right', _('up'): 'up', _('down'): 'down' }), ] MappingRule.__init__(self, *args, **kwargs)
class Mousing(MergeRule): mapping = { # "jump": Function(move_mouse), "[<button>] kick": Function(click_mouse), # "[<button>] click": Function(move_and_click_mouse), "[<button>] lick [<n500>]": Function(adjust_and_click_mouse, button="left", direction="left"), "[<button>] rick [<n500>]": Function(adjust_and_click_mouse, button="left", direction="right"), "[<button>] sick [<n500>]": Function(adjust_and_click_mouse, button="left", direction="up"), "[<button>] dick [<n500>]": Function(adjust_and_click_mouse, button="left", direction="down"), } extras = [ IntegerRef("n500", 1, 500), Choice("button", { "left": "left", "right": "right", "middle": "middle", "dub": "double" }), ] defaults = { "n100": 1, "button": 'left', }
class Mapping(dragonfly.MappingRule): mapping = cinnamon_mapping extras = [ IntegerRef('n', 1, 99), Dictation('text'), dragonfly.Choice('appname', app_map), dragonfly.IntegerRef('appnum', 1, 99), ]
class KeystrokeRule(MappingRule): exported = False mapping = grammarCfg.cmd.map extras = [ IntegerRef("n", 1, 100), IntegerRef("num", 0, 1000000), Dictation("text"), Dictation("text2"), Choice("char", specialCharMap), Choice("letters", letterMap), Choice("modifier1", modifierMap), Choice("modifier2", modifierMap), Choice("modifierSingle", singleModifierMap), Choice("pressKey", pressKeyMap), ] defaults = { "n": 1, }
class Sublime(MergeRule): mapping = { "line <n1000>": Function(go_to_line), } extras = [ IntegerRef("n1000", 1, 1000), ] defaults = {}
class DynamicCountRule(NumericDelegateRule): spec = '<dynamic> [<n>]' extras = [ IntegerRef('n', 1, 100), DictListRef('dynamic', aenea.vocabulary.register_dynamic_vocabulary('multiedit.count')), ] defaults = { 'n': 1, }
class KeystrokeRule(MappingRule): exported = False mapping = grammarCfg.cmd.map extras = [ IntegerRef("n", 1, 101), IntegerRef("num", 0, 101), IntegerRef("digit", 0, 10), IntegerRef("digit2", 0, 10), Dictation("text"), #Dictation("text2"), Choice("char", specialCharMap), Choice("letters", letterMapBothCases), #Choice("modifier1", modifierMap), #Choice("modifier2", modifierMap), #Choice("modifierSingle", singleModifierMap), #Choice("windowChars", windowCharMap), ] defaults = { "n": 1, }
class StaticCountRule(NumericDelegateRule): spec = '<static> [<n>]' extras = [ IntegerRef('n', 1, 100), DictListRef( 'static', DictList( 'static multiedit.count', aenea.vocabulary.get_static_vocabulary('multiedit.count') )), ]
class KeystrokeRule(MappingRule): exported = False extras = [ IntegerRef('n', 1, 100), Dictation('text'), Dictation('text2'), ] defaults = { 'n': 1, }
class ChromiumRule(MappingRule): mapping = aenea.configuration.make_grammar_commands('chromium', { 'open frame': Key('c-t'), 'close frame [<n>]': (Key('c-w') + Pause('40')) * Repeat(extra='n'), 'frame [<n>]': Key('c-%(n)d'), 'west [<n>]': Key('cs-tab:%(n)d'), 'east [<n>]': Key('c-tab:%(n)d'), # url 'search [<text>]': Key('c-k') + Text('%(text)s'), 'address': Key('c-l'), # search query # 'selection': Key('c-c') + Key('c-t') + Pause('90') + Key('c-v') + Key('enter'), 'quick search': Key('c-t') + Key('c-v') + Key('enter'), 'voice search': Key('c-1') + Function(mute_microphone), # find on a page 'find [<text>]': Key('c-f') + Text('%(text)s'), 'bind [<text>]': Text('/') + Pause('50') + Text('%(text)s'), 'next [<n>]': Key('c-g:%(n)d'), 'previous [<n>]': Key('cs-g:%(n)d'), 'history': Key('c-h'), 'bookmarks': Key('c-h'), # navigation 'back [<n>]': Key('a-left:%(n)d'), 'reload': Key('c-r'), # 'back [<n>]': Key('a-left:%(n)d'), -> to global 'forward [<n>]': Key('a-right:%(n)d'), # vimium 'link': Key('f'), 'new link': Key('s-f'), 'number [<n>]': Text('%(n)d'), # zoom 'zoom in [<n>]': Key('c-plus:%(n)d'), 'zoom out [<n>]': Key('c-minus:%(n)d'), # scroll slow 'slide': Key('c-0'), }) extras = [IntegerRef('n', 1, 100), Dictation('text')] defaults = { 'n': 1, 'text': '' }
class RepeatCountRule(CompoundRule): exported = False spec = "(twice|thrice|<n> ice)" extras = [IntegerRef("n", 1, 100)] def value(self, node): root = node.children[0].children[0] times = root.children[0].value() if times == "twice": return 2 elif times == "thrice": return 3 else: return times[0]
class CopyPaste(MergeRule): mapping = { "copy [<t> | <n>]": Function(copy), "paste [<t> | <n>]": Function(paste), } extras = [ Dictation("t"), IntegerRef("n",0,9) ] defaults = { "t": 'default', "n": 0 }
class MappingTerminal(MappingRule): mapping = { 'open terminal': Key('control:down, alt:down, t, control:up, alt:up'), 'cancel': Key('c-c'), # fzf 'get command [<text>]': Key('c-r') + Pause('200') + Text('%(text)s'), 'get file': Key('c-t'), 'get folder': Key('a-c'), # copy/paste terminal 'copy raw': Key('cs-c'), 'plop raw': Key('cs-v'), } extras = [IntegerRef('n', 1, 10), Dictation('text')] defaults = {'n': 1, 'text': ''}
class RepeatRule(CompoundRule): # Here we define this rule's spoken-form and special elements. spec = "<sequence> [[[and] repeat [that]] <n> times]" extras = [ sequence, # Sequence of actions defined above. IntegerRef("n", 1, 100), # Times to repeat the sequence. ] defaults = { "n": 1, # Default repeat count. } def _process_recognition(self, node, extras): # @UnusedVariable sequence = extras["sequence"] # A sequence of actions. count = extras["n"] # An integer repeat count. for i in range(count): # @UnusedVariable for action in sequence: action.execute() release.execute()
class Mapping(dragonfly.MappingRule): mapping = aenea.configuration.make_grammar_commands( 'i3wm', { '(works|workspace) <n>': Key(mod_char + "-%(n)d"), 'lock screen': Key(mod_char + "-d") + Text("i3lock") + Key("enter"), '(win|window) left': Key(mod_char + "-j"), '(win|window) right': Key(mod_char + "-semicolon"), '(win|window) up': Key(mod_char + "-l"), '(win|window) down': Key(mod_char + "-k"), 'full-screen': Key(mod_char + "-f"), '(win|window) stacking': Key(mod_char + "-s"), '(win|window) default': Key(mod_char + "-e"), '(win|window) tabbed': Key(mod_char + "-w"), '(win|window) horizontal': Key(mod_char + "-h"), '(win|window) vertical': Key(mod_char + "-v"), '(win|window) terminal': Key(mod_char + "-enter"), '(win|window) vertical (term|terminal)': Key(mod_char + "-v, a-enter"), '(win|window) horizontal (term|terminal)': Key(mod_char + "-h, a-enter"), '(win|window) (kill|close)': Key(mod_char + "s-q"), '(win|window) launch': Key(mod_char + "-d"), }) extras = [ IntegerRef('n', 1, 99), Dictation('text'), dragonfly.IntegerRef('appnum', 1, 99), ]
class KeystrokeRule(MappingRule): exported = False mapping = grammarCfg.cmd.map extras = [ IntegerRef("n", 1, 100), Dictation("text"), Dictation("text2"), Choice("char", specialCharMap), Choice("letters", letterMap), Choice("modifier1", modifierMap), Choice("modifier2", modifierMap), Choice("modifierSingle", singleModifierMap), Choice("pressKey", pressKeyMap), Choice("formatType", formatMap), Choice("abbreviation", abbreviationMap), Choice("reservedWord", reservedWord), ] defaults = { "n": 1, }
class BasicKeyboardRule(MappingRule): """Rules for bare keys and dictation.""" mapping = { _('escape'): Key('escape'), _('[<n>] backspace[s]'): Key('backspace:%(n)d'), _('[<n>] enter[s]'): Key('enter:%(n)d'), _('[<n>] tab[s]'): Key('tab:%(n)d'), _('[<n>] space[s]'): Key('space:%(n)d'), _('[<n>] delete[s]'): Key('del:%(n)d'), _('go [<n>] up'): Key('up:%(n)d'), _('go [<n>] down'): Key('down:%(n)d'), _('go [<n>] left'): Key('left:%(n)d'), _('go [<n>] right'): Key('right:%(n)d'), _('(go home|go to start)'): Key('home'), _('go [to] end'): Key('end'), _('go [<n>] page[s] up'): Key('pgup:%(n)d'), _('go [<n>] page[s] down'): Key('pgdown:%(n)d'), } extras = [Dictation('text'), IntegerRef('n', 1, 100)] defaults = {"n": 1}
class jideaRule(MappingRule): mapping = aenea.configuration.make_grammar_commands('jidea', { "all actions": Key("cs-a"), # Code execution. "run app": Key("s-f10"), "re-run app": Key("c-f5"), "run test": Key("cs-f10"), "stop running": Key("c-f2"), # Code navigation. "navigate to class <text>": Key("c-n") + Pause("30") + Function(format.pascal_case_text) + Pause("30") + Key( "enter"), "navigate to class chooser <text>": Key("c-n") + Pause("30") + Function(format.pascal_case_text) + Pause("30"), "navigate to file <text>": Key("cs-n") + Pause("30") + Function(format.camel_case_text) + Pause("30") + Key( "enter"), "navigate to file chooser <text>": Key("cs-n") + Pause("30") + Function(format.camel_case_text) + Pause("30"), "navigate to symbol <text>": Key("cas-n") + Pause("30") + Function(format.camel_case_text) + Pause("30") + Key( "enter"), "navigate to symbol chooser <text>": Key("cas-n") + Pause("30") + Function(format.camel_case_text) + Pause( "30"), "go to declaration": Key("c-b"), "go to implementation": Key("ca-b"), "go to super": Key("c-u"), "go to (class|test)": Key("cs-t"), "go back": Key("a-left"), # Project settings. "go to project window": Key("a-1"), "go to module settings": Key("f4"), "go to [project] settings": Key("ca-s"), "synchronize files": Key("ca-y"), # Terminal. "run terminal": Key("a-f12"), # Search. "find in path": Key("cs-f"), "find usages": Key("a-f7"), "find <text>": Key("c-f") + Text('%(text)s'), "replace <text>": Key("c-r") + Text('%(text)s'), # Edit. "save [file|all]": Key("c-s"), # Code. "show intentions": Key("a-enter"), "accept choice": Key("c-enter"), "go to line": Key("c-g"), "go to line <n>": Key("c-g/25") + Text("%(n)d") + Key("enter"), "[go to] start of line": Key("home"), "[go to] end of line": Key("end"), "down": Key("down"), # Window handling. "tab foo": Key("c-tab"), "tab bar": Key("cs-tab"), "close tab": Key("c-f4"), # Version control. "show diff": Key("c-d"), # Refactoring. "(refactor|re-factor) (this|choose)": Key("cas-t"), "(refactor|re-factor) rename": Key("s-f6"), "(refactor|re-factor) change signature": Key("c-f6"), "(refactor|re-factor) move": Key("f6"), "(refactor|re-factor) copy": Key("f5"), "(refactor|re-factor) safe delete": Key("a-del"), "(refactor|re-factor) extract variable": Key("ca-v"), "(refactor|re-factor) extract constant": Key("ca-c"), "(refactor|re-factor) extract field": Key("ca-f"), "(refactor|re-factor) extract parameter": Key("ca-p"), "(refactor|re-factor) extract method": Key("ca-m"), "(refactor|re-factor) (in line|inline)": Key("ca-n"), # Custom key mappings. "(run SSH session|run SSH console|run remote terminal|run remote console)": Key("a-f11/25, enter"), #debug }) extras = [ Dictation("text"), IntegerRef("n", 1, 50000) ]
alphanumeric_rule = Sequence([Literal('alphanumeric'), Repetition(RuleRef(name='z', rule=MappingRule(name='v', mapping=alphanumeric_mapping)), min=1, max=20)]) finishes = [alphabet_rule, numbers_rule, alphanumeric_rule] # Second we create a repetition of keystroke elements. # This element will match anywhere between 1 and 16 repetitions # of the keystroke elements. Note that we give this element # the name 'sequence' so that it can be used as an extra in # the rule definition below. # Note: when processing a recognition, the *value* of this element # will be a sequence of the contained elements: a sequence of # actions. sequence = Repetition(single_action, min=1, max=16, name='sequence') extras = [ sequence, # Sequence of actions defined above. IntegerRef('n', 1, 100), # Times to repeat the sequence. Alternative([Literal('hi')], name='finish'), ] #--------------------------------------------------------------------------- # Here we define the top-level rule which the user can say. class LiteralRule(CompoundRule): spec = 'literal <format_rule>' extras = [format_rule] def _process_recognition(self, node, extras): extras['format_rule'].execute(extras)
"(W C|word count) lines": Text("wc -l "), "W get ": Text("wget "), "X args": Text("xargs "), "X D O tool": Text("xdotool "), "X M L lint": Text("xmllint "), "X M L lint <text>": Text("xmllint %(text)s"), "X M L lint format": Text("xmllint -format "), "X M L lint format <text>": Text("xmllint -format %(text)s"), "X M L lint schema": Text("xmllint -schema "), "X M L lint schema <text>": Text("xmllint -schema %(text)s"), "X prop": Text("xprop "), "X win info": Text("xwininfo "), }, extras=[IntegerRef('n', 1, 10), Dictation('text')] ) context = aenea.AeneaContext( ProxyAppContext(match='regex', title='fish'), (AppContext(executable='python')) ) terminator_grammar = Grammar("Terminator general", context=context) terminator_grammar.add_rule(rules) terminator_grammar.load() def unload(): global terminator_grammar
class Mapping(dragonfly.MappingRule): mapping = window_mapping extras = [ IntegerRef('n', 1, 99), Dictation('text'), ]
class Mapping(dragonfly.MappingRule): mapping = screen_mapping extras = [ IntegerRef('n', 0, 10) ]
class MappingWindowManager(MappingRule): mapping = { # switcher 'window': Key('a-space'), 'window <windowNumber>': Key('c-f1:%(windowNumber)d'), 'my feature': Key('a-space') + Key('up') + Key('enter'), # resize 'window up': Key('control:down, win:down, up, control:up, win:up'), 'window left': Key('control:down, win:down, left, control:up, win:up'), 'window right': Key('control:down, win:down, right, control:up, win:up'), # workspaces 'workspace up': Key('control:down, alt:down, up, control:up, alt:up'), 'workspace down': Key('control:down, alt:down, down, control:up, alt:up'), 'workspace left': Key('control:down, alt:down, left, control:up, alt:up'), 'workspace right': Key('control:down, alt:down, right, control:up, alt:up'), # window workspace movements 'twitch up': Key('control:down, alt:down, shift:down, up, control:up, alt:up, shift:up'), 'twitch down': Key('control:down, alt:down, shift:down, down, control:up, alt:up, shift:up'), 'twitch left': Key('control:down, alt:down, shift:down, left, control:up, alt:up, shift:up'), 'twitch right': Key('control:down, alt:down, shift:down, right, control:up, alt:up, shift:up'), 'fullscreen': Key('f11'), # upwork timer 'stop time': Key('ca-lbracket'), 'play time': Key('ca-rbracket'), # search for Google 'look up': Key('ca-lbracket') + Key('c-4'), # 'google': Key('c-4'), # call my tts script 'speech': Key('c-lbracket'), # credentials 'my name': Text('Maxim'), 'my lastname': Text('Danilov'), 'my e-mail one': Text('*****@*****.**'), 'my e-mail two': Text('*****@*****.**'), 'private long': Text(private_data[0]), 'private short': Text(private_data[1]), 'private system': Text(private_data[2]), 'close this window': Key('a-f4'), # my launcher 'my launcher': Key('a-dot'), # system macros 'record actions': Key('c-9'), 'play actions': Key('c-0'), # call my Google voice recognition script 'say russian': Key('a-comma') + Function(mute_microphone), # 'say english': Key('a-dot'), } extras = [IntegerRef('windowNumber', 1, 10), Dictation('text')] defaults = { 'windowNumber': 1, 'text': '' }