def delete_lines(n, n2): goto_line(n) Key("V").execute() goto_line(n2) Key("d").execute()
def goto_line(n): for c in str(n): Key(c).execute() Key("G").execute()
def yank_lines(n, n2): goto_line(n) Key("V").execute() goto_line(n2) Key("y").execute()
import aenea import aenea.configuration from aenea.lax import Key from aenea import Text import dragonfly git_context = aenea.ProxyPlatformContext('linux') grammar = dragonfly.Grammar('git', context=git_context) git_mapping = aenea.configuration.make_grammar_commands( 'git', { 'git': Text("git"), 'git amend': Text("git commit --amend") + Key("enter"), 'git commit': Text("git commit") + Key("enter"), 'git pull': Text("git pull") + Key("enter"), 'git branches': Text("git branch -l") + Key("enter"), 'git status': Text("git status") + Key("enter"), 'git stat': Text("git show --stat") + Key("enter"), 'git log': Text("git log") + Key("enter"), 'git push': Text("git push") + Key("enter"), 'git diff':
def delete_lines(n, n2): goto_line(n) Key("V").execute() goto_line(n2) Key("d").execute() basics_mapping = aenea.configuration.make_grammar_commands( 'vim', { 'vim': Text("vim"), # Moving between splits 'split-left': Key("escape, c-h"), 'split-left <n>': Key("escape, c-h:%(n)d"), 'split-right': Key("escape, c-l"), 'split-right <n>': Key("escape, c-l:%(n)d"), 'split-up': Key("escape, c-k"), 'split-down': Key("escape, c-j"), 'split-close': Key("escape, colon, q, enter"), 'open [in] split': Key("s"), 'open [in] tab':
def switch_app(appname): aenea.communications.server.switch_app(appname, 1) def switch_app_numbered(appname, appnum): aenea.communications.server.switch_app(appname, appnum) def switch_app_title(text): aenea.communications.server.switch_app(text, 1) cinnamon_mapping = aenea.configuration.make_grammar_commands( 'cinnamon', { 'works one': Key("ca-1"), 'works two': Key("ca-2"), 'works left': Key("ca-left"), 'works right': Key("ca-right"), 'lock screen': Key("ca-l"), # Switching applications 'switch (application|app)': Key("a-tab"), '(focus|folk) <appname>': Function(switch_app), '(focus|folk) <appname> <appnum>': Function(switch_app_numbered), '(focus|folk) title <text>': Function(switch_app_title), }) class Mapping(dragonfly.MappingRule): mapping = cinnamon_mapping
# Commands for interatcting with Google Chrome import aenea import aenea.configuration from aenea.lax import Key, Text, Dictation import dragonfly from aenea import * chrome_mapping = { '(preev|left) tab': Key("cs-tab"), '(next|right) tab': Key("c-tab"), 'new (window|tab)': Key("w-t"), 'reopen (window|tab)': Key("ws-t"), 'close (window|tab)': Key("w-w"), 'close all (windows|tab)': Key("ws-w"), 'go back': Key("w-lbracket"), 'go forward': Key("w-rbracket"), 'go to': Key("w-l"), 'refresh': Key("w-r"), 'link|show links|links': Key("f"), 'link new': Key("s-f"), 'easy proxy that': Key("cs-e"), 'easy proxy and zotero that': Key("cs-o"), 'zotero that': Key("cs-z"), 'mort': Key("j:10"), 'lest': Key("k:10"), 'edit in vim': Key("f12"), # Searching 'jump till <text>': Key("escape, slash") + Text("%(text)s") + Key("enter"), 'previous [<n>]': Key("s-N:%(n)d"),
# Commands for interatcting with MS Word import aenea import aenea.configuration from aenea.lax import Key, Text, Dictation import dragonfly from aenea import * msw_context = aenea.ProxyCustomAppContext(id="Microsoft Word") grammar = dragonfly.Grammar('msw', context=msw_context) msw_mapping = { "new comment": Key("wa-a"), "toggle track changes": Key("ws-e"), } class MappingMSW(dragonfly.MappingRule): mapping = msw_mapping extras = [ IntegerRef("n", 1, 10), ] alternatives = [] alternatives.append(RuleRef(rule=MappingMSW())) root_action = Alternative(alternatives) sequence = Repetition(root_action, min=1, max=3, name="sequence")
# Author: Tony Grosinger # # Licensed under LGPL import aenea import aenea.configuration from aenea.lax import Key from aenea import IntegerRef import dragonfly tmux_context = aenea.ProxyPlatformContext('linux') grammar = dragonfly.Grammar('tmux', context=tmux_context) tmux_mapping = aenea.configuration.make_grammar_commands( 'tmux', { 'team (right|next)': Key("c-b, n"), 'team (left|previous)': Key("c-b, p"), 'team create': Key("c-b, c"), 'team <n>': Key("c-b, %(n)d"), 'team rename': Key("c-b, comma"), 'team exit': Key("c-b, backslash"), 'team detach': Key("c-b, d"), 'team [pane] vertical': Key("c-b, percent"), 'team [pane] horizontal': Key("c-b, dquote"), 'team swap': Key("c-b, o"), 'team pane up': Key("c-b, up"), 'team pane down': Key("c-b, down"), 'team pane left': Key("c-b, left"), 'team pane right': Key("c-b, right"), 'team pane close': Key("c-b, x") })
import aenea import aenea.misc import aenea.configuration import dragonfly awesome_context = aenea.ProxyPlatformContext('linux') grammar = dragonfly.Grammar('awesome', context=awesome_context) awesome = 'W' from aenea.lax import Key basics_mapping = aenea.configuration.make_grammar_commands('awesome', { 'termie': Key(awesome + '-enter'), '(whim | notion | ion) screen': Key(awesome + 'c-k'), '(whim | notion | ion) up': Key(awesome + '-k'), '(whim | notion | ion) down': Key(awesome + '-j'), '(whim | notion | ion) left': Key(awesome + 's-k'), '(whim | notion | ion) right': Key(awesome + 's-j'), '(whim | notion | ion) change screen [<n>]': Key(awesome + '-o:%(n)d'), '(whim | notion | ion) close client': Key(awesome + 's-c'), '(whim | notion | ion) snap': Key(awesome + 'c-enter'), '(whim | notion | ion) full': Key(awesome + '-m'), '(whim | notion | ion) [work] <n>': Key(awesome + '-%(n)d'), '(whim | notion | ion) tag <n>': Key(awesome + 'sc-%(n)d'), '(whim | notion | ion) tag marked <n>': Key(awesome + 's-%(n)d'), '(whim | notion | ion) move marked <n>': Key(awesome + 's-%(n)d') })
import aenea import aenea.configuration from aenea.lax import Key from aenea import Text import dragonfly finder_context = aenea.ProxyCustomAppContext(id="Finder") grammar = dragonfly.Grammar('Finder', context=finder_context) finder_mapping = aenea.configuration.make_grammar_commands( 'finder', { "sort by name": Key("cw-1"), # "sort by kind": Key("cw-2"), "sort by opened": Key("cw-3"), "sort by added": Key("cw-4"), "sort by modified": Key("cw-5"), "sort by size": Key("cw-6"), "go back": Key("w-lbracket"), "go forward": Key("w-rbracket"), }) class Mapping(dragonfly.MappingRule): mapping = finder_mapping grammar.add_rule(Mapping()) grammar.load()
import aenea import aenea.configuration from aenea.lax import Key from aenea import Text import dragonfly docker_context = aenea.ProxyPlatformContext('linux') grammar = dragonfly.Grammar('docker', context=docker_context) docker_mapping = aenea.configuration.make_grammar_commands( 'docker', { '(docker|darker|doctor)': Text("sudo docker "), '(docker|darker|doctor) build': Text("sudo docker build .") + Key("enter"), '(docker|darker|doctor) build (tag|tagged)': Text("sudo docker build -t \"\" .") + Key("left:3"), '(docker|darker|doctor) list images': Text("sudo docker images") + Key("enter"), '(docker|darker|doctor) list containers': Text("sudo docker ps -a") + Key("enter"), '(docker|darker|doctor) stop': Text("sudo docker stop "), '(docker|darker|doctor) (remove|delete) image': Text("sudo docker rmi "), '(docker|darker|doctor) (remove|delete) [container]': Text("sudo docker rm "), '(docker|darker|doctor) run': Text("sudo docker run -d "), '(docker|darker|doctor) inspect':
# Commands for interacting with omnifocus import aenea import aenea.configuration from aenea.lax import Key, Text, Dictation import dragonfly from aenea import * do_mapping = { 'new task': Key("w-n"), '[go] to inbox': Key("aw-1"), '(omni go to)|(omni jump to)': Key("w-o"), 'omni synchronize': Key("cw-s"), 'planning mode': Key("w-1"), 'context mode': Key("w-2"), '(star|flag) that': Key("sw-l"), 'review that': Key("sw-r"), } do_context = aenea.ProxyCustomAppContext(id="OmniFocus") do_grammar = dragonfly.Grammar('OmniFocus', context=do_context) ########## class MappingDo(dragonfly.MappingRule): mapping = do_mapping do_grammar.add_rule(MappingDo())
# # Licensed under LGPL import aenea import aenea.configuration from aenea.lax import Key, Text, Dictation from aenea import (IntegerRef) import dragonfly firefox_context = aenea.ProxyCustomAppContext( executable="/usr/lib/firefox/firefox") grammar = dragonfly.Grammar('firefox', context=firefox_context) window_mapping = { # Tab navigation 'page (previous|left)': Key("cs-tab"), 'page (next|right)': Key("c-tab"), 'page (home|first)': Key("g, s-h"), 'page (end|last)': Key("g, s-l"), 'page new': Key("c-t"), 'page reopen': Key("cs-t"), 'page close': Key("c-w"), '[page] back': Key("s-h"), '[page] forward': Key("s-l"), 'refresh': Key("r"), 'link': Key("f"), 'link new': Key("s-f"), # Moving around 'more': Key("d"), 'less': Key("u"),
# # Author: Tony Grosinger # # Licensed under LGPL import aenea import aenea.configuration from aenea.lax import Key from aenea import IntegerRef import dragonfly screen_context = aenea.ProxyPlatformContext('linux') grammar = dragonfly.Grammar('screen', context=screen_context) screen_mapping = aenea.configuration.make_grammar_commands('screen', { 'screen (right|next)': Key("c-a, n"), 'screen (left|previous)': Key("c-a, p"), 'screen create': Key("c-a, c"), 'screen <n>': Key("c-a, %(n)d"), 'screen rename': Key("c-a, s-a"), 'screen exit': Key("c-a, backslash"), 'screen [split] vertical': Key("c-a, bar"), 'screen [split] horizontal': Key("c-a, s-s"), 'screen split next': Key("c-a, tab") }) class Mapping(dragonfly.MappingRule): mapping = screen_mapping extras = [
# # Licensed under LGPL import aenea import aenea.configuration from aenea.lax import Key, Text, Dictation from aenea import (IntegerRef) import dragonfly chrome_context = aenea.ProxyCustomAppContext( executable="/opt/google/chrome/chrome") grammar = dragonfly.Grammar('chrome', context=chrome_context) window_mapping = { # Tab navigation 'page (previous|left)': Key("cs-tab"), 'page (next|right)': Key("c-tab"), 'page <n>': Key("c-%(n)d"), 'page new': Key("c-t"), 'page reopen': Key("cs-t"), 'page close': Key("c-w"), 'page back': Key("s-h"), 'page forward': Key("s-l"), 'refresh': Key("r"), 'link': Key("f"), 'link new': Key("s-f"), # Moving around 'more': Key("j:10"), 'less': Key("k:10"), 'top': Key("g, g"),
def create_private_function(text): Text('def _%s(' % format_snake_case(text)).execute() def create_public_function(text): Text('def %s(' % format_snake_case(text)).execute() python_mapping = aenea.configuration.make_grammar_commands('python', { 'new class [named] <text>': Function(create_class), 'new [public] (function|func) [named] <text>': Function(create_public_function), 'new private (function|func) [named] <text>': Function(create_private_function), 'close (function|func)': Text("):\n"), 'comment': Key("escape, i") + Text("# "), # Python "true": Text("True"), "false": Text("False"), '(none|null|nil)': Text("None"), 'print line': Text("print()") + Key("left"), "class method": Text("@classmethod\n"), "(def|define)": Text("def "), "(dict|dictionary)": Text("dict("), "set": Text("set("), 'array': Key("lbracket, enter, enter, up, tab"), "sum": Text("sum("), "(len|length)": Text("len("), "list": Text("list("), "tuple": Text("tuple("),
import aenea import aenea.configuration from aenea.lax import Key from aenea import Text import dragonfly # For now this file will also cover all other iTerm2 commands git_context = aenea.ProxyCustomAppContext(id="iTerm2") grammar = dragonfly.Grammar('git', context=git_context) git_mapping = aenea.configuration.make_grammar_commands( 'git', { 'git': Text("git"), 'git amend': Text("git commit --amend") + Key("enter"), 'git stash': Text("git stash") + Key("enter"), 'git commit': Text("git commit") + Key("enter"), 'git commit all': Text("git commit -av") + Key("enter"), 'git pull': Text("git pull") + Key("enter"), 'git branches': Text("git branch -l") + Key("enter"), 'git status': Text("git status") + Key("enter"), 'git push': Text("git push") + Key("enter"), 'git diff': Text("git diff") + Key("enter"), 'git log': Text("git lg") + Key("enter"), # lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative # Incomplete Commands 'git add': Text("git add "), 'git add force': Text("git add -f "), 'git clone': Text("git clone "),
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), ]
# Commands for interacting with MailMail import aenea import aenea.configuration from aenea.lax import Key, Text, Dictation import dragonfly from aenea import * mm_mapping = { 'open [message]': Key("w-o"), 'edit as new [message]': Key("asw-d"), 'forward [message]': Key("sw-f"), 'reply [message]': Key("w-r"), 'reply all': Key("ws-r"), 'new [message]': Key("w-n"), 'copy as link': Key("saw-c"), 'select thread': Key("cw-a"), '[go] to inbox': Key("g, i"), '[go] to sent': Key("g, t"), '[go] to archive': Key("g, a"), '[go] to robots': Key("g, r"), '[go] to outbound': Key("g, o"), '[go] to mailing lists': Key("g, m"), '[go] to (mailbox|label)': Key("w-t"), '[go] to (mailbox|label) <text>': Key("w-t") + Text("%(text)s") + Key("enter"), '[go] to list': Key("0"), '[go] to message': Key("9"), '[go] to editor': Key("c-j"), # working ? 'archive [message]': Key("sw-m"), 'junk [message]': Key("sw-j"),
# Commands for interacting with Zotero import aenea import aenea.configuration from aenea.lax import Key, Text, Dictation import dragonfly from aenea import * zotero_mapping = { 'add tag': Key("c-t"), 'add note': Key("c-n"), 'copy bibtex': Key("c-b"), 'copy formatted reference': Key("c-r"), 'copy [zotero] link': Key("c-z"), 'focus info': Key("c-i"), 'edit (info|that)': Key("c-e"), 'delete tags': Key("c-d"), 'delete tags': Key("c-d"), '(get|retrieve) meta-data': Key("c-m"), 'rename attachments': Key("c-a"), } zotero_context = aenea.ProxyCustomAppContext(id="Zotero") zotero_grammar = dragonfly.Grammar('Zotero', context=zotero_context) ########## class MappingZotero(dragonfly.MappingRule): mapping = zotero_mapping extras = [ IntegerRef('n', 1, 60), Dictation('text'),
import dragonfly try: import aenea.communications except ImportError: print 'Unable to import Aenea client-side modules.' raise terminal_context = aenea.ProxyPlatformContext('linux') grammar = dragonfly.Grammar('terminal', context=terminal_context) terminal_mapping = aenea.configuration.make_grammar_commands( 'terminal', { # Terminal commands # dir is hard to say and recognize. Use something else 'deer up': Text("cd ..") + Key("enter"), 'deer list': Text("ls") + Key("enter"), 'deer list all': Text("ls -lha") + Key("enter"), 'deer list details': Text("ls -lh") + Key("enter"), 'deer into': Text("cd "), '(terminal|term) clear': Text("clear") + Key("enter"), '(terminal|term) left': Key("c-pgup"), '(terminal|term) right': Key("c-pgdown"), '(terminal|term) new [tab]': Key("cs-t"), '(terminal|term) (close|exit)': Key("c-c") + Text("exit") + Key("enter"), # Common words '(pseudo|sudo|pseudo-)': Text("sudo "), '(apt|app) get': Text("sudo apt-get "), '(apt|app) get install': Text("sudo apt-get install "),