Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add user setting for hiss debounce time #1700

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions core/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
Map noises (like pop) to actions so they can have contextually differing behavior
"""

from talon import Module, actions, cron, noise
from talon import Module, actions, cron, noise, settings

mod = Module()
hiss_cron = None

mod.setting(
"hiss_scroll_debounce_time",
type=int,
default=100,
desc="How much time a hiss must last for to be considered a hiss rather than part of speech, in ms",
)


@mod.action_class
class Actions:
Expand All @@ -31,7 +38,10 @@ def noise_trigger_hiss_debounce(active: bool):
"""Since the hiss noise triggers while you're talking we need to debounce it"""
global hiss_cron
if active:
hiss_cron = cron.after("100ms", lambda: actions.user.noise_trigger_hiss(active))
hiss_cron = cron.after(
str(settings.get("user.hiss_scroll_debounce_time")) + "ms",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest using an F-string maybe, but otherwise looks good to me

Suggested change
str(settings.get("user.hiss_scroll_debounce_time")) + "ms",
f"{settings.get("user.hiss_scroll_debounce_time")}ms",

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm I thought we had flynt running automatically in CI to do that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f-string would be nicer than explicitly converting, true. I originally wanted to be more explicit about the ms

lambda: actions.user.noise_trigger_hiss(active),
)
else:
cron.cancel(hiss_cron)
actions.user.noise_trigger_hiss(active)
Expand Down
4 changes: 4 additions & 0 deletions settings.talon
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ settings():
# If `true`, use a hissing noise to scroll continuously
user.mouse_enable_hiss_scroll = false

# How much time a hiss must last for to be considered a hiss rather than
# part of speech, in ms
user.hiss_scroll_debounce_time = 100

# If `true`, hide the continuous scroll/gaze scroll GUI
user.mouse_hide_mouse_gui = false

Expand Down
Loading