-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit for talon voice commands
- Loading branch information
0 parents
commit e39c53a
Showing
12 changed files
with
1,071 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.DS_store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
from talon.voice import Context, Key, press, Str | ||
from user.utils import parse_words_as_integer | ||
|
||
# It is recommended to use this script in tandem with Vimium, | ||
# a Google Chrome plugin for controlling the browser via keyboard | ||
# https://vimium.github.io/ | ||
|
||
context = Context('GoogleChrome', bundle='com.google.Chrome') | ||
|
||
|
||
def open_focus_devtools(m): | ||
press('cmd-shift-c') | ||
|
||
|
||
def show_panel(name): | ||
open_focus_devtools(None) | ||
|
||
# Open command menu | ||
press('cmd-shift-p') | ||
|
||
Str('Show %s' % (name))(None) | ||
press('enter') | ||
|
||
|
||
def next_panel(m): | ||
open_focus_devtools(None) | ||
press('cmd-]') | ||
|
||
|
||
def last_panel(m): | ||
open_focus_devtools(None) | ||
press('cmd-[') | ||
|
||
|
||
def focus_address_bar(m): | ||
press('cmd-l') | ||
|
||
|
||
def search(m): | ||
press('cmd-m') | ||
|
||
|
||
def quit(m): | ||
press('cmd-q') | ||
|
||
|
||
def scroll_to_top(m): | ||
press('g') | ||
press('g') | ||
|
||
|
||
def print_page(m): | ||
press('cmd-p') | ||
|
||
|
||
# Return focus from the dev-tools to the page | ||
def refocus_page(m): | ||
focus_address_bar(None) | ||
|
||
# Escape button | ||
# This leaves the focus on the page at previous tab focused point, not the beginning of the page | ||
press('escape') | ||
|
||
|
||
def back(m): | ||
refocus_page(None) | ||
press('cmd-[') | ||
|
||
|
||
def forward(m): | ||
refocus_page(None) | ||
press('cmd-]') | ||
|
||
|
||
def jump_tab(m): | ||
tab_number = parse_words_as_integer(m._words[1:]) | ||
if tab_number is not None and 0 < tab_number < 9: | ||
press('cmd-%s' % tab_number) | ||
|
||
|
||
context.keymap({ | ||
'address bar': focus_address_bar, | ||
'search': search, | ||
'print': print_page, | ||
'top': scroll_to_top, | ||
'quit': quit, | ||
|
||
'back[ward]': back, | ||
'forward': forward, | ||
'reload': Key('cmd-r'), | ||
'hard reload': Key('cmd-shift-r'), | ||
|
||
'new tab': Key('cmd-t'), | ||
'close tab': Key('cmd-w'), | ||
'(reopen | unclose) tab': Key('cmd-shift-t'), | ||
|
||
'next tab': Key('cmd-alt-right'), | ||
'(last | prevous) tab': Key('cmd-alt-left'), | ||
|
||
'tab (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8)': jump_tab, | ||
'(end | rightmost) tab': Key('cmd-9'), | ||
|
||
'find': Key('cmd-f'), | ||
'next': Key('cmd-g'), | ||
|
||
'(last | prevous)': Key('cmd-shift-g'), | ||
|
||
# dev tools | ||
'toggle dev tools': Key('cmd-alt-i'), | ||
'command [menu]': Key('cmd-shift-p'), | ||
'next panel': next_panel, | ||
'(last | prevous) panel': last_panel, | ||
'[show] application [panel]': lambda m: show_panel('Application'), | ||
'[show] audit[s] [panel]': lambda m: show_panel('Audits'), | ||
'[show] console [panel]': lambda m: show_panel('Console'), | ||
'[show] element[s] [panel]': lambda m: show_panel('Elements'), | ||
'[show] memory [panel]': lambda m: show_panel('Memory'), | ||
'[show] network [panel]': lambda m: show_panel('Network'), | ||
'[show] performance [panel]': lambda m: show_panel('Performance'), | ||
'[show] security [panel]': lambda m: show_panel('Security'), | ||
'[show] source[s] [panel]': lambda m: show_panel('Sources'), | ||
|
||
'refocus page': refocus_page, | ||
'[refocus] dev tools': open_focus_devtools, | ||
|
||
# Clipboard | ||
'cut': Key('cmd-x'), | ||
'copy': Key('cmd-c'), | ||
'paste': Key('cmd-v'), | ||
'paste same style': Key('cmd-alt-shift-v'), | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from talon.voice import Context, Key | ||
|
||
ides = { | ||
"com.jetbrains.intellij", | ||
"com.jetbrains.intellij.ce", | ||
"com.jetbrains.AppCode", | ||
"com.jetbrains.CLion", | ||
"com.jetbrains.datagrip", | ||
"com.jetbrains.goland", | ||
"com.jetbrains.PhpStorm", | ||
"com.jetbrains.pycharm", | ||
"com.jetbrains.rider", | ||
"com.jetbrains.rubymine", | ||
"com.jetbrains.WebStorm", | ||
"com.google.android.studio", | ||
} | ||
|
||
|
||
ctx = Context('phpstorm', func=lambda app, win: any( | ||
i in app.bundle for i in ides)) | ||
|
||
keymap = { | ||
'comment declaration': ['/**', Key('space')], | ||
'comment block': ['/**', Key('enter')], | ||
|
||
'(dupe | duplicate)': Key('cmd-d'), | ||
'import class': Key('alt-enter enter'), | ||
'quickfix': Key('alt-enter'), | ||
'go class': Key('cmd-o'), | ||
'go file': Key('cmd-shift-o'), | ||
'(go implement | go definition)': Key('cmd-b'), | ||
'preev method': Key('ctrl-up'), | ||
'neck method': Key('ctrl-down'), | ||
'refactor': Key('shift-f6'), | ||
'generate': Key('cmd-n'), | ||
'recent': Key('cmd-e'), | ||
|
||
'replace': Key('cmd-r'), | ||
'find action': Key('cmd-shift-a'), | ||
'settings': Key('cmd-,'), | ||
'grab': Key('alt-up'), | ||
'shrink': Key('alt-down'), | ||
'close': Key('cmd-w'), | ||
# 'rename': Key('shift-f6'), | ||
'move file': Key('f6'), | ||
'global search': Key('shift shift'), | ||
'go to file': Key('cmd-shift-n'), | ||
'format': Key('cmd-alt-l'), | ||
'expand': Key('cmd-+'), | ||
'collapse': Key('cmd--'), | ||
'erase line': Key('cmd-backspace'), | ||
'last change': Key('cmd-shift-backspace'), | ||
'((open | close) terminal | terminal (open | close) | toggle terminal | terminal)': Key('alt-f12'), | ||
'snip left': Key('cmd-shift-left delete'), | ||
'snip right': Key('cmd-shift-right delete'), | ||
'move up': Key('alt-shift-up'), | ||
'move down': Key('alt-shift-down'), | ||
'path': Key('cmd-shift-f'), | ||
'funk up': Key('cmd-shift-up'), | ||
'funk down': Key('cmd-shift-down'), | ||
'(breadcrumbs | crumbs)': Key('cmd-up'), | ||
|
||
} | ||
|
||
|
||
ctx.keymap(keymap) | ||
|
||
|
||
def unload(): ctx.unload() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from talon.voice import Context, Key | ||
|
||
ides = { | ||
"com.jetbrains.PhpStorm", | ||
} | ||
|
||
|
||
ctx = Context('phpstorm', func=lambda app, win: any( | ||
i in app.bundle for i in ides)) | ||
|
||
keymap = { | ||
'(phiz | fizz)': ['php', Key('tab')], | ||
# 'search': [Key('shift'), Key('shift')], | ||
'golf': ['fore', Key('tab')], | ||
'chop': ['forek', Key('tab')], | ||
'bat': ['?=', Key('tab')], | ||
'if': ['if', Key('tab')], | ||
'complete': Key('cmd-shift-enter'), | ||
'definition': Key('alt-space'), | ||
} | ||
|
||
|
||
ctx.keymap(keymap) | ||
|
||
|
||
def unload(): ctx.unload() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from talon.voice import Context, Key | ||
|
||
ctx = Context('slack', bundle='com.tinyspeck.slackmacgap') | ||
|
||
keymap = { | ||
'channel': Key('cmd-k'), | ||
'channel last': Key('alt-up'), | ||
'channel next': Key('alt-down'), | ||
'tools command': ['``', Key('left')], | ||
'tools code': ['``````', Key('left left left return return up')], | ||
} | ||
|
||
ctx.keymap(keymap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from talon.voice import Context, Key | ||
|
||
ides = { | ||
"com.spotify.client", | ||
} | ||
|
||
|
||
ctx = Context('phpstorm', func=lambda app, win: any( | ||
i in app.bundle for i in ides)) | ||
|
||
keymap = { | ||
'(play | pause)': Key('space'), | ||
'search': Key('cmd-l'), | ||
'(lower volume | quieter)': Key('cmd-down'), | ||
'((pump | raise) volume | louder)': Key('cmd-up'), | ||
'(next song | next | next track)': Key('cmd-right'), | ||
'(last song | last | last track)': Key('cmd-left'), | ||
} | ||
|
||
|
||
ctx.keymap(keymap) | ||
|
||
|
||
def unload(): ctx.unload() |
Oops, something went wrong.