From e1032140b53a8ce40abefa4fc273257e4d33a554 Mon Sep 17 00:00:00 2001 From: Ian Markind Date: Fri, 28 Dec 2018 00:38:08 -0500 Subject: [PATCH] Updated switcher --- bit-bucket.py | 110 +++++++++++++++++++++++++------------------------- jetbrains.py | 3 +- switcher.py | 28 ++++++++----- 3 files changed, 74 insertions(+), 67 deletions(-) diff --git a/bit-bucket.py b/bit-bucket.py index ed74f12..15a0c40 100644 --- a/bit-bucket.py +++ b/bit-bucket.py @@ -1,55 +1,55 @@ -from talon.voice import Context, Key - -ctx = Context('bit-bucket', func=lambda app, win: 'Bitbucket' in win.title) - -keymap = { - # All Pages - 'shortcuts': Key('?'), - 'left navigation': Key('['), - 'site search': Key('/'), - - # Most Pages (except your work and repository source) - 'omnibar': Key('.'), - 'next item': Key('j'), - 'last item': Key('k'), - 'selected': Key('o'), - 'dashboard': Key('g d'), - 'settings': Key('g a'), - 'remove focus': Key('esc'), - 'go back': Key('u'), - 'right navigation': Key(']'), - - # Repository source - 'focus': Key('f'), - - # Repository pages (except source) - 'create': Key('c r'), - 'import': Key('i r'), - 'source': Key('r s'), - 'view commits': Key('r c'), - 'view branches': Key('r b'), - 'pull requests': Key('r p'), - 'issues': Key('r i'), - 'wiki': Key('r w'), - 'downloads': Key('r d'), - 'repo settings': Key('r a'), - 'find file': Key('f'), - - # Repository pages (except source and settings) - 'fork': Key('x f'), - 'create branch': Key('x b'), - 'compare': Key('x c'), - 'create pull request': Key('x p'), - 'create issue': Key('x i'), - - # Pull Requests - 'submit comment': Key('ctrl+enter'), - 'inline comments': Key('t c'), - 'diff tab': Key('p d'), - 'commits tab': Key('p c'), - 'activity tab': Key('p a'), - 'show tasks': Key('shift-t'), - -} - -ctx.keymap(keymap) +# from talon.voice import Context, Key +# +# ctx = Context('bit-bucket', func=lambda app, win: 'Bitbucket' in win.title) +# +# keymap = { +# # All Pages +# 'shortcuts': Key('?'), +# 'left navigation': Key('['), +# 'site search': Key('/'), +# +# # Most Pages (except your work and repository source) +# 'omnibar': Key('.'), +# 'next item': Key('j'), +# 'last item': Key('k'), +# 'selected': Key('o'), +# 'dashboard': Key('g d'), +# 'settings': Key('g a'), +# 'remove focus': Key('esc'), +# 'go back': Key('u'), +# 'right navigation': Key(']'), +# +# # Repository source +# 'focus': Key('f'), +# +# # Repository pages (except source) +# 'create': Key('c r'), +# 'import': Key('i r'), +# 'source': Key('r s'), +# 'view commits': Key('r c'), +# 'view branches': Key('r b'), +# 'pull requests': Key('r p'), +# 'issues': Key('r i'), +# 'wiki': Key('r w'), +# 'downloads': Key('r d'), +# 'repo settings': Key('r a'), +# 'find file': Key('f'), +# +# # Repository pages (except source and settings) +# 'fork': Key('x f'), +# 'create branch': Key('x b'), +# 'compare': Key('x c'), +# 'create pull request': Key('x p'), +# 'create issue': Key('x i'), +# +# # Pull Requests +# 'submit comment': Key('ctrl+enter'), +# 'inline comments': Key('t c'), +# 'diff tab': Key('p d'), +# 'commits tab': Key('p c'), +# 'activity tab': Key('p a'), +# 'show tasks': Key('shift-t'), +# +# } +# +# ctx.keymap(keymap) diff --git a/jetbrains.py b/jetbrains.py index 379b6a4..5979e28 100644 --- a/jetbrains.py +++ b/jetbrains.py @@ -270,7 +270,8 @@ def is_real_jetbrains_editor(app, window): "import class": Key("alt-enter enter"), "quickfix": Key("alt-enter"), "go class": Key("cmd-o"), - "go file": Key("cmd-shift-o"), + "go file": idea("action GotoFile"), + # "go file": Key("cmd-shift-o"), "(go implement | go definition)": Key("cmd-b"), "preev method": Key("ctrl-up"), "neck method": Key("ctrl-down"), diff --git a/switcher.py b/switcher.py index 94f9c2c..2c5ac09 100644 --- a/switcher.py +++ b/switcher.py @@ -7,8 +7,10 @@ launch = {} -def switch_app(m): - name = str(m['switcher.running'][0]) +def switch_app(m, name=None): + if name is None: + name = str(m['switcher.running'][0]) + full = running.get(name) if not full: return for app in ui.apps(): @@ -19,8 +21,10 @@ def switch_app(m): break -def launch_app(m): - name = str(m['switcher.launch'][0]) +def launch_app(m, name=None): + if name is None: + name = str(m['switcher.launch'][0]) + path = launch.get(name) if path: ui.launch(path=path) @@ -30,14 +34,16 @@ def launch_app(m): ctx.keymap({ 'focus {switcher.running}': switch_app, 'launch {switcher.launch}': launch_app, + # custom switchers here + "fox chrome": lambda x: switch_app(x, "Google Chrome"), + "fox storm": lambda x: switch_app(x, "PhpStorm"), + "fox web storm": lambda x: switch_app(x, "WebStorm"), + "fox pie charm": lambda x: switch_app(x, "PyCharm"), + "start storm": lambda x: launch_app(x, "PhpStorm"), + "start web storm": lambda x: launch_app(x, "WebStorm"), + "start pie charm": lambda x: launch_app(x, "PyCharm"), }) -applications = ( - '/Applications', - '/Applications/Photoshop', - '/Applications/Utilities', - '/Applications/JetBrains/apps/WebStorm', -) def update_lists(): global running @@ -55,7 +61,7 @@ def update_lists(): ctx.set_list('running', running.keys()) new = {} - for base in applications: + for base in '/Applications', '/Applications/Utilities': for name in os.listdir(base): path = os.path.join(base, name) name = name.rsplit('.', 1)[0]