Skip to content

Commit

Permalink
modes: simplify modes a little bit (talonhub#1215)
Browse files Browse the repository at this point in the history
talonhub#1122

We want to reduce the use of `mode:all` and instead have files that
specifically target specific modes. This breaks up the existing sleep
files to better capture their semantics and adds some comments.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and rokubop committed Nov 6, 2023
1 parent 1e004e2 commit b808ae3
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 22 deletions.
29 changes: 29 additions & 0 deletions core/modes/sleep_mode.talon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,32 @@ settings():
user.mouse_enable_pop_click = 0
# Stop mouse scroll down using hiss noise
user.mouse_enable_hiss_scroll = 0

#================================================================================
# Commands to wake Talon
#================================================================================

# Note: these have repeaters on them (+) to work around an issue where, in sleep mode,
# you can get into a situation where these commands are difficult to trigger.

# These commands are fully anchored (^ and $), which means that there must be
# silence before and after saying them in order for them to recognize (this reduces
# false positives during normal sleep mode, normally a good thing).

# However, ignored background speech during sleep mode also counts as an utterance.

# Thus, if you say "blah blah blah talon wake", these won't trigger, because "blah
# blah blah" was part of the same utterance. You have to say "blah blah blah" <pause,
# wait for speech timeout>, "talon wake" <pause, wait for speech timeout>.

# Sometimes people would forget the second pause, notice things weren't working, and
# say "talon wake" over and over again before the speech timeout ever gets hit, which
# means that these won't recognize. The (+) handles this case, so if you say
# <pause> "talon wake talon wake" <pause>, it'll still work.

^(welcome back)+$:
user.mouse_wake()
user.history_enable()
user.talon_mode()

^(talon wake)+$: speech.enable()
9 changes: 9 additions & 0 deletions core/modes/sleep_mode_not_dragon.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mode: sleep
not speech.engine: dragon
-
# We define this *only* if the speech engine isn't Dragon, because if you're using Dragon,
# "wake up" is used to specifically control Dragon, and not affect Talon.
#
# It's a useful and well known command, though, so if you're using any other speech
# engine, this controls Talon.
^(wake up)+$: speech.enable()
26 changes: 26 additions & 0 deletions core/modes/to_sleep_mode.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
mode: command
mode: dictation
-

# The optional <phrase> afterwards allows these to match even if you say arbitrary text
# after this command, without having to wait for the speech timeout.

# This is handy because you often need to put Talon asleep in order to immediately
# talk to humans, and it's annoying to have to say "sleep all", wait for the timeout,
# and then resume your conversation.

# With this, you can say "sleep all hey bob" and Talon will immediately go to
# sleep and ignore "hey bob". Note that subtitles will show "sleep all hey bob",
# because it's part of the rule definition, but "hey bob" will be ignored, because
# we don't do anything with the <phrase> in the body of the command.

^sleep all [<phrase>]$:
user.switcher_hide_running()
user.history_disable()
user.homophones_hide()
user.help_hide()
user.mouse_sleep()
speech.disable()
user.engine_sleep()

^talon sleep [<phrase>]$: speech.disable()
12 changes: 12 additions & 0 deletions core/modes/to_sleep_mode_not_dragon.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mode: command
mode: dictation
not speech.engine: dragon
-
# We define this *only* if the speech engine isn't Dragon, because if you're using Dragon,
# "go to sleep" is used to specifically control Dragon, and not affect Talon.
#
# It's a useful and well known command, though, so if you're using any other speech
# engine, this controls Talon.
#
# For a note about the optional <phrase>, see to_sleep_mode.talon.
^go to sleep [<phrase>]$: speech.disable()
17 changes: 0 additions & 17 deletions core/modes/wake_and_sleep.talon

This file was deleted.

5 changes: 0 additions & 5 deletions core/modes/wake_and_sleep_wav2letter.talon

This file was deleted.

0 comments on commit b808ae3

Please sign in to comment.