-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pop_twice_to_wake and pop_twice_to_repeat functions (#1398)
Following on from #1364 Haven't seen that PR change much over the past few weeks, I've been using that functionality in my personal repo and it's been great so I wanted to make sure other users got to try it out. ## Changes from #1364 - Switched to tag at request of @pokey in review - This will prevent blocking on other pop commands - Added Module import to be able to define tag - Updated context matcher to look for `user.pop_twice_to_wake` - Dropped changes to mouse.py --- - Merged with #1399 as per discussion in grooming session - Add explanation comments - Switch double pop time minimum and maximum to a user.setting --------- Co-authored-by: Guenther Schmitz <727316+gpunktschmitz@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com> Co-authored-by: Jeff Knaus <knaus.jeff@gmail.com>
- Loading branch information
1 parent
0a6a001
commit e78c752
Showing
3 changed files
with
89 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,44 @@ | ||
import time | ||
|
||
from talon import Context, Module, actions, settings | ||
|
||
ctx = Context() | ||
mod = Module() | ||
|
||
mod.tag("pop_twice_to_wake", desc="tag for enabling pop twice to wake in sleep mode") | ||
|
||
mod.setting( | ||
"double_pop_speed_minimum", | ||
type=float, | ||
desc="""Shortest time in seconds to accept a second pop to trigger additional actions""", | ||
default=0.1, | ||
) | ||
|
||
mod.setting( | ||
"double_pop_speed_maximum", | ||
type=float, | ||
desc="""Longest time in seconds to accept a second pop to trigger additional actions""", | ||
default=0.3, | ||
) | ||
|
||
ctx.matches = r""" | ||
mode: sleep | ||
and tag: user.pop_twice_to_wake | ||
""" | ||
|
||
time_last_pop = 0 | ||
|
||
|
||
@ctx.action_class("user") | ||
class UserActions: | ||
def noise_trigger_pop(): | ||
# Since zoom mouse is registering against noise.register("pop", on_pop), let that take priority | ||
if actions.tracking.control_zoom_enabled(): | ||
return | ||
global time_last_pop | ||
double_pop_speed_minimum = settings.get("user.double_pop_speed_minimum") | ||
double_pop_speed_maximum = settings.get("user.double_pop_speed_maximum") | ||
delta = time.perf_counter() - time_last_pop | ||
if delta >= double_pop_speed_minimum and delta <= double_pop_speed_maximum: | ||
actions.speech.enable() | ||
time_last_pop = time.perf_counter() |
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,30 @@ | ||
import time | ||
|
||
from talon import Context, Module, actions, settings | ||
|
||
ctx = Context() | ||
mod = Module() | ||
|
||
mod.tag("pop_twice_to_repeat", desc="tag for enabling pop twice to repeat") | ||
|
||
ctx.matches = r""" | ||
mode: command | ||
and tag: user.pop_twice_to_repeat | ||
""" | ||
|
||
time_last_pop = 0 | ||
|
||
|
||
@ctx.action_class("user") | ||
class UserActions: | ||
def noise_trigger_pop(): | ||
# Since zoom mouse is registering against noise.register("pop", on_pop), let that take priority | ||
if actions.tracking.control_zoom_enabled(): | ||
return | ||
global time_last_pop | ||
delta = time.perf_counter() - time_last_pop | ||
double_pop_speed_minimum = settings.get("user.double_pop_speed_minimum") | ||
double_pop_speed_maximum = settings.get("user.double_pop_speed_maximum") | ||
if delta >= double_pop_speed_minimum and delta <= double_pop_speed_maximum: | ||
actions.core.repeat_command() | ||
time_last_pop = time.perf_counter() |
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