-
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.
fixed mouse.py for new talon update v0.8
- Loading branch information
Showing
3 changed files
with
202 additions
and
202 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
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 |
---|---|---|
@@ -1,79 +1,79 @@ | ||
# from talon.voice import Word, Context, Key, Rep, Str, press | ||
# from talon import ui | ||
# import time | ||
# import os | ||
# | ||
# running = {} | ||
# launch = {} | ||
# | ||
# | ||
# def switch_app(m): | ||
# name = str(m['switcher.running'][0]) | ||
# full = running.get(name) | ||
# if not full: return | ||
# for app in ui.apps(): | ||
# if app.name == full: | ||
# app.focus() | ||
# # TODO: replace sleep with a check to see when it is in foreground | ||
# time.sleep(0.25) | ||
# break | ||
# | ||
# | ||
# def launch_app(m): | ||
# name = str(m['switcher.launch'][0]) | ||
# path = launch.get(name) | ||
# if path: | ||
# ui.launch(path=path) | ||
# | ||
# | ||
# ctx = Context('switcher') | ||
# ctx.keymap({ | ||
# 'focus {switcher.running}': switch_app, | ||
# 'launch {switcher.launch}': launch_app, | ||
# }) | ||
# | ||
# applications = ( | ||
# '/Applications', | ||
# '/Applications/Photoshop', | ||
# '/Applications/Utilities', | ||
# '/Applications/JetBrains/apps/WebStorm', | ||
# ) | ||
# | ||
# def update_lists(): | ||
# global running | ||
# global launch | ||
# new = {} | ||
# for app in ui.apps(): | ||
# if app.background and not app.windows(): | ||
# continue | ||
# words = app.name.split(' ') | ||
# for word in words: | ||
# if word and not word in new: | ||
# new[word] = app.name | ||
# new[app.name] = app.name | ||
# running = new | ||
# ctx.set_list('running', running.keys()) | ||
# | ||
# new = {} | ||
# for base in applications: | ||
# for name in os.listdir(base): | ||
# path = os.path.join(base, name) | ||
# name = name.rsplit('.', 1)[0] | ||
# new[name] = path | ||
# words = name.split(' ') | ||
# for word in words: | ||
# if word and word not in new: | ||
# if len(name) > 6 and len(word) < 3: | ||
# continue | ||
# new[word] = path | ||
# launch = new | ||
# ctx.set_list('launch', launch.keys()) | ||
# | ||
# | ||
# def ui_event(event, arg): | ||
# if event in ('app_activate', 'app_launch', 'app_close', 'win_open', 'win_close'): | ||
# update_lists() | ||
# | ||
# | ||
# ui.register('', ui_event) | ||
# update_lists() | ||
from talon.voice import Word, Context, Key, Rep, Str, press | ||
from talon import ui | ||
import time | ||
import os | ||
|
||
running = {} | ||
launch = {} | ||
|
||
|
||
def switch_app(m): | ||
name = str(m['switcher.running'][0]) | ||
full = running.get(name) | ||
if not full: return | ||
for app in ui.apps(): | ||
if app.name == full: | ||
app.focus() | ||
# TODO: replace sleep with a check to see when it is in foreground | ||
time.sleep(0.25) | ||
break | ||
|
||
|
||
def launch_app(m): | ||
name = str(m['switcher.launch'][0]) | ||
path = launch.get(name) | ||
if path: | ||
ui.launch(path=path) | ||
|
||
|
||
ctx = Context('switcher') | ||
ctx.keymap({ | ||
'focus {switcher.running}': switch_app, | ||
'launch {switcher.launch}': launch_app, | ||
}) | ||
|
||
applications = ( | ||
'/Applications', | ||
'/Applications/Photoshop', | ||
'/Applications/Utilities', | ||
'/Applications/JetBrains/apps/WebStorm', | ||
) | ||
|
||
def update_lists(): | ||
global running | ||
global launch | ||
new = {} | ||
for app in ui.apps(): | ||
if app.background and not app.windows(): | ||
continue | ||
words = app.name.split(' ') | ||
for word in words: | ||
if word and not word in new: | ||
new[word] = app.name | ||
new[app.name] = app.name | ||
running = new | ||
ctx.set_list('running', running.keys()) | ||
|
||
new = {} | ||
for base in applications: | ||
for name in os.listdir(base): | ||
path = os.path.join(base, name) | ||
name = name.rsplit('.', 1)[0] | ||
new[name] = path | ||
words = name.split(' ') | ||
for word in words: | ||
if word and word not in new: | ||
if len(name) > 6 and len(word) < 3: | ||
continue | ||
new[word] = path | ||
launch = new | ||
ctx.set_list('launch', launch.keys()) | ||
|
||
|
||
def ui_event(event, arg): | ||
if event in ('app_activate', 'app_launch', 'app_close', 'win_open', 'win_close'): | ||
update_lists() | ||
|
||
|
||
ui.register('', ui_event) | ||
update_lists() |
Oops, something went wrong.