Ejemplo n.º 1
0
class TermiteRule(MappingRule):
    mapping = {
        "(bigger|zoom in)": Key("c-plus"),
        "(smaller|zoom out)": Key("c-minus"),
    }
    extras = [
        Dictation("text"),
        Integer("n", 0, 9),
    ]
Ejemplo n.º 2
0
class SlackRule(MappingRule):
    mapping = {
        "[slack] channel <text>": Key("escape, c-k") + Text("%(text)s"),
        "(quit|leave|part|close) channel": Text("/leave") + Key("enter"),
        "Mark [channel] read": Key("escape, escape"),
    }
    extras = [
        Dictation("text"),
    ]
Ejemplo n.º 3
0
class DCSRule(MappingRule):
    mapping = {
        "radio": Key("backslash"),
        "radio <n>": Key("f%(n)d"),
        "(radio exit|exit radio)": Key("f12"),
        "refuel and rearm": radio_menu(8, 1),
        "request repair": radio_menu(8, 3),
        "ground power (on|connect|attach)": radio_menu(8, 2, 1),
        "ground power (off|disconnect|remove|attach)": radio_menu(8, 2, 2),
    }
    extras = [
        Dictation("text"),
        Integer("n", 0, 9),
    ]
Ejemplo n.º 4
0
def radio_menu(*args):
    keys = ["backslash/20"]
    for number in args:
        keys.append("f%s/20" % number)
    key_spec = ", ".join(keys)

    print "radio_menu -> Key('%s')" % key_spec
    return Key(key_spec)
Ejemplo n.º 5
0
class GmailRule(MappingRule):
    mapping = {
        "archive": Key("y"),
        "mute": Key("m"),
        "next": Key("k"),
        "inbox": Key("g, i"),
        "oldest": Key("j:100"),
        "newest": Key("k:100"),
        "read [that]": Key("o"),
        "(expand|show all)": Key(";"),
    }
Ejemplo n.º 6
0
def ctld(*args):
    """Operate the CTLD radio menu in DCS.

    Takes integers as args, specifying the CTLD sub-menu options to select.
    """
    keys = ["backslash/20", "f10/20", "f6/20"]
    for number in args:
        keys.append("f%s/20" % number)
    key_spec = ", ".join(keys)

    print "ctld -> Key('%s')" % key_spec
    return Key(key_spec)
Ejemplo n.º 7
0
 def _process_recognition(self, node, extras):
     query = smash_case(str(extras["text"]))
     focus_terminal()
     Text("findedit ").execute()
     Text(query).execute()
     Key("enter").execute()
Ejemplo n.º 8
0
 def _process_recognition(self, node, extras):
     query = smash_case(str(extras["text"]))
     Key("a-g").execute()
     Pause("50").execute()
     Text(query).execute()
Ejemplo n.º 9
0
 def _process_recognition(self, node, extras):
     Key("space, c-t").execute()
     Text(smash_case(extras["text"])).execute()
Ejemplo n.º 10
0
 def _process_recognition(self, node, extras):
     Text("git checkout ").execute()
     Text(kebab_case(extras["text"])).execute()
     Key("enter").execute()
Ejemplo n.º 11
0
class BashRule(MappingRule):
    mapping = {
        "new session <text>":
        Text("tmux new-session -t %(text)s") + Key("enter"),
        "(attach|connect) session <text>":
        Text("tmux attach -t %(text)s") + Key("tab, enter"),
        "list sessions":
        Text("tmux list-sessions") + Key("enter"),
        "(rerun last|do again|do it again|run again)":
        Key("up, enter"),
        "(git|get) reset hard":
        Text("git reset --hard") + Key("enter"),
        "(git|get|show) diff":
        Text("git diff") + Key("enter"),
        "(git|get|show) status":
        Text("git status") + Key("enter"),
        "(git|get) stash":
        Text("git stash") + Key("enter"),
        "[(git|get)] (stash pop|pop stash)":
        Text("git stash pop") + Key("enter"),
        "[(git|get)] (stash show|show stash)":
        Text("git stash show -p") + Key("enter"),
        "(git|get) pull":
        Text("git pull") + Key("enter"),
        "(git|get) fetch [all]":
        Text("git fetch --all") + Key("enter"),
        "[show] (git|get) log":
        Text("fzf-git-log") + Key("enter"),
        "[(git|get)] commit [patch]":
        Text("git commit -p") + Key("enter"),
        "[(git|get)] push":
        Text("git push") + Key("enter"),
        "[(git|get)] push force":
        Text("git push --force"),
        "[(git|get)] push [(this|new)] branch [to origin]":
        Text("git push -u origin (git rev-parse --abbrev-ref HEAD)") +
        Key("enter"),
        "[(git|get)] rebase on master":
        Text("git fetch origin && git rebase origin/master") + Key("enter"),
        "[(git|get)] rebase abort":
        Text("git rebase --abort") + Key("enter"),
        "[(git|get)] commit all":
        Text("git commit --all") + Key("enter"),
        "abort [(git|get)] rebase":
        Text("git rebase --abort") + Key("enter"),
        "chudder":
        Key("a-g"),
        "(chudder|folder|directory|go) home":
        Text("cd ~") + Key("enter"),
        "(chudder|folder|directory) up":
        Text("cd ..") + Key("enter"),
        "Lang Lang":
        Text("exa -la") + Key("enter"),
        "(show|list) [docker] containers":
        Text("docker ps -a") + Key("enter"),
        "show environment":
        Text("env") + Key("enter"),
        "(show|list) tasks":
        Text("task ls") + Key("enter"),
        "grep [for] <text>":
        Text("rg %(text)s") + Key("enter"),
        "grep that for <text>":
        Key("c-p") + Text(" | rg -i %(text)s") + Key("enter"),
        "findedit <text>":
        Text("findedit %(text)s") + Key("enter"),
        "grepedit <text>":
        Text("grepedit %(text)s") + Key("enter"),
        "findedit <text> here":
        Text("findedit %(text)s $PWD") + Key("enter"),
        "grepedit <text> here":
        Text("grepedit %(text)s $PWD") + Key("enter"),
        "(switch|google|cube|kubernetes|kates) project":
        Text("kzf-project") + Key("enter"),
        "(switch|google|cube|kubernetes|kates) project <text>":
        Text("kzf-project %(text)s") + Key("enter"),
        "(switch|cube|kubernetes|kates) cluster":
        Text("kzf-cluster") + Key("enter"),
        "(switch|cube|kubernetes|kates) cluster <text>":
        Text("kzf-cluster %(text)s") + Key("enter"),
        "(switch|cube|kubernetes|kates) namespace":
        Text("kzf-namespace") + Key("enter"),
        "(switch|cube|kubernetes|kates) namespace <text>":
        Text("kzf-namespace %(text)s") + Key("enter"),
        "(cube|kubernetes|kates) get pods":
        Text("kubectl get pods") + Key("enter"),
        "tail (pod|log|logs)":
        Text("kzf-tail") + Key("enter"),
        "tail (pod|log|logs) <text>":
        Text("kzf-tail %(text)s") + Key("enter"),
    }
    extras = [
        Dictation("text"),
        Integer("n", 0, 9),
    ]
Ejemplo n.º 12
0
 def _process_recognition(self, node, extras):
     Key("c-x, b").execute()
     Text(smash_case(extras["text"])).execute()
     Key("enter").execute()
Ejemplo n.º 13
0
 def _process_recognition(self, node, extras):
     Key("a-x").execute()
     Pause("10").execute()
     Text(smash_case(str(extras["text"]))).execute()
     Key("enter").execute()
Ejemplo n.º 14
0
 def _process_recognition(self, node, extras):
     print "JumpWord1Rule: " + str(extras["text"])
     Key("c-c, f6, e").execute()
     Pause("20").execute()
     Key(nato_to_char(str(extras["text"]))[0]).execute()
Ejemplo n.º 15
0
class TmuxRule(MappingRule):
    mapping = {
        "(connect|attach) [session]":
        Text("tmux attach") + Key("enter"),
        "new (window|tab|shell|terminal)":
        Key("c-b, c"),
        "rename (window|tab|shell|terminal) <text>":
        Key("c-b, comma") + Key("backspace:50") + Text("%(text)s") +
        Key("enter"),
        "rename session <text>":
        Key("c-b, dollar") + Key("backspace:50") + Text("%(text)s") +
        Key("enter"),
        "(window|shell|terminal) <n>":
        Key("c-b, %(n)d"),
        "(disconnect|detach) session":
        Key("c-b, d"),
        "(jump|switch|select|choose) session":
        Key("c-b, w"),
        "switch":
        Key("c-b, w"),
        "switch <n>":
        Key("c-b, %(n)d"),
    }
    extras = [
        Dictation("text"),
        Integer("n", 0, 9),
    ]
Ejemplo n.º 16
0
def focus_terminal():
    focus_aenea_client()
    Key("cas-1").execute()
    Pause("20").execute()
Ejemplo n.º 17
0
class BrowserRule(MappingRule):
    mapping = {
        "top":
        Key("home"),
        "bottom":
        Key("end"),
        "down":
        Key("pgdown"),
        "up":
        Key("pgup"),
        "links":
        Key("escape") + Pause("10") + Key("f"),
        "go back":
        Key("escape") + Pause("10") + Key("s-h"),
        "go forward":
        Key("escape") + Pause("10") + Key("s-l"),
        "open <text>":
        Key("a-home") + Pause("50") + Key("escape") + Pause("10") + Key("o") +
        Pause("10") + Text("%(text)s"),
        "(search|google) [for] <text>":
        Key("a-home") + Pause("50") + Text("%(text)s"),
        "close":
        Key("c-w"),
        "reload":
        Key("cs-r"),
        "(bigger|zoom in)":
        Key("cs-plus"),
        "(smaller|zoom out)":
        Key("cs-minus"),
        "refresh":
        Key("cs-r"),
        "close tab":
        Key("c-w"),
        "tab <n>":
        Key("c-%(n)d"),
        "new window":
        Key("c-n"),
        "new tab":
        Key("c-t"),
        "browse <text>":
        Key("c-l") + Text("%(text)s") + Key("enter"),
        "browse history <text>":
        Key("c-l") + Text("%(text)s") + Key("down"),
        #"slack channel <text>": Key("c-k") + Text("%(text)s"),
    }
    extras = [
        Dictation("text"),
        Integer("n", 0, 9),
    ]
Ejemplo n.º 18
0
class DiscordRule(MappingRule):
    mapping = {
        "[discord] channel": Key("escape, c-k") + Text("%(text)s"),
    }
Ejemplo n.º 19
0
 def _process_recognition(self, node, extras):
     letters = nato_to_char(str(extras["text"]))
     Key(', '.join(letters)).execute()
Ejemplo n.º 20
0
def switch_awesome_tag(n):
    """Switch to Awesome tag number n"""
    focus_aenea_client()
    keystroke = "cas-%s" % n
    Key(keystroke).execute()
Ejemplo n.º 21
0
class WindowManagementRule(MappingRule):
    mapping = {
        "abort":
        Key("c-c"),
        "escape":
        Key("escape"),
        "(twin|double) escape":
        Key("escape, escape"),
        "[focus] window up":
        Key("s-up"),
        "[focus] window down":
        Key("s-down"),
        "[focus] window left":
        Key("s-left"),
        "[focus] window right":
        Key("s-right"),
        "[focus] frame up":
        Key("ca-up"),
        "[focus] frame down":
        Key("ca-down"),
        "[focus] frame left":
        Key("ca-left"),
        "[focus] frame right":
        Key("ca-right"),
        "(make master|master frame|frame master|center frame)":
        Key("ca-enter"),
        "left master":
        Key("ca-left, ca-left, ca-enter"),
        "right master":
        Key("ca-right, ca-right, ca-enter"),
        "[focus] (next|other) (screen|monitor)":
        Key("cw-j"),
        "spank":
        Key("enter"),
        "(twin|double|hard) spank":
        Key("enter") + Pause("50") + Key("enter"),
        "yes":
        Key("y, enter"),
        "no":
        Key("n, enter"),
        "markdown bullet <text>":
        Key("space, asterisk, space") + Text("%(text)s") + Key("space"),
        "soft string <text>":
        Key("quote") + Text("%(text)s") + Key("quote"),
        "(search back|retro search)":
        Key("c-r"),
        "(search back|retro search) <text>":
        Key("c-r") + Pause("50") + Text("%(text)s"),
        "hoover [<n>]":
        Key("a-backspace:%(n)d"),
        "slurp [<n>]":
        Key("a-backspace:%(n)d"),
        "maximise":
        Key("w-m"),
        "say clipboard":
        OriginalKey("cas-e"),
        "go up":
        Key("up"),
        "go down":
        Key("down"),
        "go [to the] (top|start)":
        Key("home"),
        "go [to the] (bottom|end)":
        Key("end"),
        "page up":
        Key("pgup"),
        "page down":
        Key("pgdown"),
        "cut [that]":
        Key("c-x"),
        "copy [that]":
        Key("c-c"),
        "shift copy [that]":
        Key("cs-c"),
        "Delete [that]":
        Key("delete"),
        "paste [that]":
        Key("c-v"),
        "Tabular":
        Key("tab"),
        "Twin tabular":
        Key("tab") + Pause("10") + Key("tab"),
        "[left] click":
        Mouse("left"),
        "(right click|crick)":
        Mouse("right"),
        "middle click":
        Mouse("middle"),
    }
    extras = [
        Dictation("text"),
        Integer("n", 1, 9),
    ]
    defaults = {
        "n": 1,
    }
Ejemplo n.º 22
0
class EmacsRule(MappingRule):
    mapping = {
        "clang":
        Key("c-g:2"),
        "yank":
        Key("c-y"),
        "one window":
        Key("c-x, 1"),
        "two windows":
        Key("c-x, 1, c-x, 3"),
        "three windows":
        Key("c-x, 1, c-x, 3, c-x, 3, c-x, plus"),
        "four windows":
        Key("c-x, 1, c-x, 2, c-x, 3, s-down, c-x, 3, c-x, plus"),
        "six windows":
        Key("c-x, 1, c-x, 2, c-x, 3, c-x, 3, s-down, c-x, 3, c-x, 3, c-x, plus"
            ),
        "balance windows":
        Key("c-x, plus"),
        "(kill|close) window":
        Key("c-x, 0"),
        "kill buffer":
        Key("c-x, k"),
        "kill word":
        Key("a-d"),
        "save [buffer]":
        Key("c-x, c-s"),
        "done with buffer":
        Key("c-x, hash"),
        "retro word":
        Key("a-b"),
        "pro word":
        Key("a-f"),
        "kill line":
        Key("c-k"),
        "kill whole line":
        Key("c-a, c-a, c-k, c-k"),
        "window right":
        Key("s-right"),
        "window far right":
        Key("s-right:4"),
        "window left":
        Key("s-left"),
        "window far left":
        Key("s-left:4"),
        "window down":
        Key("s-down"),
        "window up":
        Key("s-up"),
        "jump window":
        Key("c-x, o"),
        "open line":
        Key("c-e, a-o"),
        "save (buffer|file)":
        Key("c-x, c-s"),
        "Centre view":
        Key("c-u, 1, 0, c-l"),
        "(no no|nono)":
        Key("cs-minus"),
        "(duplicate|dupe|double) (line|region|that)":
        Key("c-c, d"),
        "(top|start) [of] buffer":
        Key("as-comma"),
        "(bottom|end) [of] buffer":
        Key("as-dot"),
        "start [of] line":
        Key("c-a"),
        "end [of] line":
        Key("c-e"),
        "(search forward|pro search) <text>":
        Key("c-s") + Text("%(text)s"),
        "(search forward|pro search)":
        Key("c-s"),
        "occurrences":
        Key("c-o"),
        "(mark|set mark)":
        Key("cas-space"),
        "jump line":
        Key("c-c, f6, l"),
        "jump word":
        Key("c-c, f6, w"),
        "(show|list) buffers":
        Key("c-x, c-b"),
        "untab":
        Key("s-escape"),
    }

    extras = [
        Dictation("text"),
        Integer("n", 1, 9),
    ]