コード例 #1
0
ファイル: outlook.py プロジェクト: kartikkwatra/community-1
@mod.action_class
class Actions:
    def email_reply():
        "Reply to email"
        key('cmd-r')

    def email_send():
        "Send current email"
        key('cmd-enter')

    def pane_next():
        "Go to next pane"
        key('shift-ctrl-[')

    def pane_previous():
        "Go to previous pane"
        key('shift-ctrl-]')


ctx = Context()
ctx.on({'app.bundle': 'com.microsoft.Outlook'})

ctx.commands = {
    'reply to email': lambda m: self.email_reply(),
    'send email': lambda m: self.email_send(),
    'next pain': lambda m: self.pane_next(),
    'preev pain': lambda m: self.pane_previous(),
    # 'dismiss outlook',
}
コード例 #2
0
        elif word in tens_map:
            result += tens_map[word]
        elif word in teens_map:
            result += teens_map[word]
    return result


@ctx.capture(
    'number',
    rule=
    f'<number_small> [{alt_scales} ([and] (<number_small> | {alt_scales} | <number_small> {alt_scales}))*]'
)
def number(m):
    return fuse_num(fuse_scale(fuse_num(fuse_scale(list(m), 3))))[0]


@ctx.capture('number_signed', rule=f'[negative] <number>')
def number_signed(m):
    number = m[-1]
    if m[0] == 'negative':
        return -number
    return number


ctx.commands = {
    'digit <digits>+': lambda m: actions.insert(''.join(map(str, m.digits))),
    # '<number_small>':  lambda m: print('small',  m.number_small),
    'number <number_signed>':
    lambda m: actions.insert(str(m.number_signed[0])),
}
コード例 #3
0
ファイル: switcher.py プロジェクト: kartikkwatra/community-1
            app.focus()
            # TODO: replace sleep with a registered callback
            for i in range(25):
                if ui.active_app().bundle == bundle:
                    break
                time.sleep(0.01)
            time.sleep(0.05)

    def launch(path: str):
        """Launch a new application by path"""
        ui.launch(path=path)


ctx = Context()
ctx.commands = {
    'focus {self.running}': lambda m: actions.self.focus(m.running),
    'launch {self.launch}': lambda m: actions.self.launch(m.launch),
}

def update_lists():
    new = {}
    for app in ui.apps():
        if app.background and not app.windows():
            continue
        words = app.name.lower().split(' ')
        for word in words:
            if word and not word in new:
                new[word] = app.bundle
        new[app.name] = app.bundle
    ctx.lists['self.running'] = new

    new = {}
コード例 #4
0
from talon import Context, speech_system, actions
from talon_plugins import speech

ctx = Context()

def set_enabled(value):
    ctx.exclusive = not value
    actions.speech.toggle(value)

ctx.commands = {
    'talon sleep': lambda m: set_enabled(False),
    'talon wake': lambda m: set_enabled(True),

    'dragon mode': [lambda m: set_enabled(False), lambda m: speech_system.engine_mimic('wake up'.split())],
    'talon mode': [lambda m: set_enabled(True), lambda m: speech_system.engine_mimic('go to sleep'.split())],
}
コード例 #5
0

@mod.action_class
class Actions:
    def split_horizontal():
        "Split current pane (horizontal)"
        key('cmd-shift-d')

    def split_vertical():
        "Split current pane (vertical)"
        key('cmd-d')

    def pane_next():
        "Go to next pane"
        key('cmd-]')

    def pane_previous():
        "Go to previous pane"
        key('cmd-[')


ctx = Context()
ctx.on({'app.bundle': 'com.googlecode.iterm2'})

ctx.commands = {
    'split horizontal': lambda m: self.split_horizontal(),
    'split vertical': lambda m: self.split_vertical(),
    'pane next': lambda m: self.pane_next(),
    'pane last': lambda m: self.pane_previous(),
}
コード例 #6
0
ファイル: keys.py プロジェクト: kartikkwatra/community-1

@ctx.capture(
    rule='(<self.arrow> | <self.number> | <self.letter> | <self.special>)')
def any(m) -> str:
    for name in ('arrow', 'number', 'letter', 'special'):
        value = m.get(name)
        if value is not None:
            return value
    raise AttributeError(f'No key found in capture: {m}')


@ctx.capture(rule='[<self.modifiers>] <self.any>')
def key(m) -> str:
    key = m.any
    mods = m.get('modifiers', None)
    if mods:
        mods = '-'.join(mods[0])
        key = f'{mods}-{key}'
    return key


ctx.commands = {
    'go <self.arrow>': lambda m: actions.key(m.arrow),
    '<self.number>': lambda m: actions.key(m.number),
    '<self.letter>': lambda m: actions.key(m.letter),
    '<self.symbol>': lambda m: actions.key(m.symbol),
    '<self.special>': lambda m: actions.key(m.special),
    '<self.key>': lambda m: actions.key(m.key),
}
コード例 #7
0
ファイル: dictation.py プロジェクト: kartikkwatra/community-1
    actions.insert(yellsmash)


# Voice Commands
ctx.commands = {
    # word word word ...
    '(say | phrase) <dgndictation> [over]': dictate.lower,
    # Word word word ...
    'sentence <dgndictation>': sentence,
    # wordwordword ...
    'smash <dgndictation>': smash,
    # word_word_word ...
    'snake <dgndictation>': snake,
    'dotsnik <dgndictation>': dotsnake,
    # word-word-word ...
    '(spine | kebab) <dgndictation>': spine,
    # wordWordWord ...
    '(camel | cram) <dgndictation>': camel,
    # Word Word and Word ...
    'title <dgndictation>': title,
    # WORD WORD WORD ...
    '(yell | allcaps | yeller) <dgndictation>': yell,
    # WORD_WORD_WORD ...
    '(yellsnake | yellsnik) <dgndictation>': yellsnake,
    # WORDWORDWORD ...
    'yellsmash <dgndictation>': yellsmash,
    # word/word/word ...
    'pathway <dgndictation>': pathway,
    # word.word.word ...
    'dotsway <dgndictation>': dotsway,
}
コード例 #8
0
ファイル: preview.py プロジェクト: kartikkwatra/community-1
from talon import Module, Context, actions

key = actions.key
self = actions.self

mod = Module()


@mod.action_class
class Actions:
    def highlight():
        "FIXME: Highlight what?"
        key('cmd-ctrl-h')

    def note():
        "FIXME: Note what?"
        key('cmd-ctrl-n')


ctx = Context()
ctx.on({'app.bundle': 'com.apple.Preview'})

ctx.commands = {
    'highlight': lambda m: self.highlight(),
    'note': lambda m: self.note(),
}
コード例 #9
0
ファイル: mouse.py プロジェクト: kartikkwatra/community-1
# Click and drag
def backdated_drag(m):
    ctrl.mouse_click(x, y, down=True, wait=16000)


def backdated_release(m):
    ctrl.mouse_click(x, y, up=True, wait=16000)


# Scrolling with mouse wheel
def scroll_down(m):
    ctrl.mouse_scroll(200)


def scroll_up(m):
    ctrl.mouse_scroll(-200)


# Voice commands
ctx.commands = {
    'click': backdated_click,
    '(right click | righty)': backdated_rightclick,
    'dub click': backdated_dubclick,
    '(trip click | triplick)': backdated_tripclick,
    '(drag | press | hold)': backdated_drag,
    'release': backdated_release,
    'shift click': shift_click,
    'command click': command_click,
    '(scroll down | wheel down)': scroll_down,
    '(scroll up | wheel up)': scroll_up,
}
コード例 #10
0
ファイル: emoji.py プロジェクト: kartikkwatra/community-1

# FIXME: move this into the slack app script
ctx = Context()
ctx.on({'app.bundle': 'com.tinyspeck.slackmacgap'})


def react(m):
    emoji = m.emoji[0]
    edit.select_all()
    with clip.capture() as s:
        edit.copy()

    insert(f"+{emoji}\n")
    try:
        insert(s.get())
    except clip.NoChange:
        pass


# TODO: use a mapping list instead?
@ctx.capture(rule='|'.join(emojis.keys()))
def emoji(m):
    return emojis[' '.join(m)]


ctx.commands = {
    'inline <self.emoji>': lambda m: insert(m.emoji[0]),
    'react <self.emoji>': react,  # lambda m: slack.react(m.emoji[0]),
}