forked from talonhub/community
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchrome.py
54 lines (45 loc) · 1.07 KB
/
chrome.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from talon import Context, Module, actions, app
ctx = Context()
mod = Module()
mod.apps.chrome = "app.name: Google Chrome"
mod.apps.chrome = r"""
os: windows
and app.exe: /^chrome\.exe$/i
"""
mod.apps.chrome = """
os: mac
app.bundle: com.google.Chrome
app.bundle: com.google.Chrome.canary
app.bundle: org.chromium.Chromium
"""
mod.apps.chrome = """
os: linux
app.exe: chrome
app.exe: chromium-browser
app.exe: chromium
"""
mod.apps.chrome = """
os: linux
and app.name: Google-chrome
"""
ctx.matches = r"""
app: chrome
"""
@mod.action_class
class Actions:
def chrome_mod(key: str):
"""Press the specified key with the correct modifier key for the OS"""
if app.platform == "mac":
actions.key(f"cmd-{key}")
else:
actions.key(f"ctrl-{key}")
@ctx.action_class("user")
class UserActions:
def tab_close_wrapper():
actions.sleep("180ms")
actions.app.tab_close()
@ctx.action_class("browser")
class BrowserActions:
def show_extensions():
actions.app.tab_open()
actions.browser.go("chrome://extensions")