Skip to content

Commit

Permalink
Updated switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
TestPlan committed Dec 28, 2018
1 parent 1e51a21 commit e103214
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 67 deletions.
110 changes: 55 additions & 55 deletions bit-bucket.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 2 additions & 1 deletion jetbrains.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
28 changes: 17 additions & 11 deletions switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit e103214

Please sign in to comment.