You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Customization/basic_customization.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,20 +14,20 @@ So why do we have two kinds of configuration/scripting files (`.py` and `.talon`
14
14
15
15
-`.talon` files provide a succinct way of mapping spoken commands to behaviour. `.talon` files are written in a language that is only used by Talon.
16
16
-`.talon` files are designed to be simple and to provide good feedback if you make mistakes.
17
-
-`.py` files are Python scripts which provide the implementation of behaviour and other functionality used by `.talon` files.
17
+
-`.py` files are Python scripts that provide the implementation of behaviour and other functionality used by `.talon` files.
18
18
- You do not need to customize Python or know how to code to use Talon
19
19
20
20
## Managing your customizations
21
21
22
22
Talon is built to be a flexible and customizable system. This means that in addition to being able to add new voice commands you can also override the behavior of existing commands reasonably easily.
23
23
24
-
Given this flexibility there are two ways you could approach customizing your Talon setup:
24
+
Given this flexibility, there are two ways you could approach customizing your Talon setup:
25
25
26
26
- Option A: Edit the `.talon` and `.py` files from the [Talon Community](https://github.com/talonhub/community) directly.
27
27
- Can be easier to begin with, but may be difficult to keep up-to-date with upstream.
28
28
- You need to work out what you modified and how to re-apply it to the [Talon Community](https://github.com/talonhub/community) user file set every time you update it.
29
29
- Option B: Maintain your own separate directory with your customizations that sits alongside the [Talon Community](https://github.com/talonhub/community). (**Recommended**)
30
-
- The screenshot below shows a Talon user directory with multiple user file sets. The `community` directory contains the [Talon Community](https://github.com/talonhub/community) unchanged from the version on Github. The rest of the folders are other file sets that supplement the Talon Community file set.
30
+
- The screenshot below shows a Talon user directory with multiple user file sets. The `community` directory contains the [Talon Community](https://github.com/talonhub/community) unchanged from the version on GitHub. The rest of the folders are other file sets that supplement the Talon Community file set.
31
31
- For example, `my_talon` contains personal customizations, and `curserless-talon` contains the [Cursorless](https://github.com/cursorless-dev/cursorless).
32
32
33
33

@@ -40,7 +40,7 @@ You will probably want to update your Talon Community user file set occasionally
40
40
41
41
Let's make a new voice command that presses the key combination `cmd+a` or `control+a` when you say "select everything".
42
42
43
-
Open up a text editor and save an empty file called `simple_test.talon` somewhere in your Talon user directory. Next, rightclick on the Talon icon in your status bar, choose scripting, and then 'View log'. This will show a list of log messages from Talon, and in particular will be where Talon tells us if there's a problem with what we write in `simple_test.talon`.
43
+
Open up a text editor and save an empty file called `simple_test.talon` somewhere in your Talon user directory. Next, right-click on the Talon icon in your status bar, choose 'Scripting', and then 'View log'. This will show a list of log messages from Talon, and in particular, will be where Talon tells us if there's a problem with what we write in `simple_test.talon`.
44
44
45
45
OK, let's get to defining the command. If you're running MacOS, copy/paste the following into your editor and save the file (ensure you have the spaces at the start of the 'key' line):
46
46
@@ -56,7 +56,7 @@ select everything:
56
56
key(ctrl-a)
57
57
```
58
58
59
-
You should see a line like `2021-09-02 17:33:36 DEBUG [+] /home/normal/.talon/user/mystuff/simple_test.talon` printed in your Talon log. This indicates that Talon has picked up your new/updated file and has loaded it. In general Talon will automatically pick up and apply any changes to `.talon` or `.py` files in your Talon user directory, so you don't have to restart Talon each time you make a change. If you don't see a line like that and can't figure it out, then you might want to ask for help on the [Talon slack](https://talonvoice.com/chat) in the #help channel.
59
+
You should see a line like `2021-09-02 17:33:36 DEBUG [+] /home/normal/.talon/user/mystuff/simple_test.talon` printed in your Talon log. This indicates that Talon has picked up your new/updated file and has loaded it. In general, Talon will automatically pick up and apply any changes to `.talon` or `.py` files in your Talon user directory, so you don't have to restart Talon each time you make a change. If you don't see a line like that and can't figure it out, then you might want to ask for help on the [Talon slack](https://talonvoice.com/chat) in the #help channel.
60
60
61
61
Your command should now be defined, so if you focus your text editor and say "select everything" it should indeed select everything.
62
62
@@ -150,7 +150,7 @@ The part above the '-' line is called the "context header" and the part below is
150
150
151
151
The context header defines when the rest of the file will be active.
152
152
153
-
In this example our context header says that the file is only active when the word 'Gmail' is in the window title. The context header is optional; if it is not included (as in our simple_test.talon example) then the file is always active.
153
+
In this example, our context header says that the file is only active when the word 'Gmail' is in the window title. The context header is optional; if it is not included (as in our simple_test.talon example) then the file is always active.
154
154
155
155
### Body
156
156
@@ -162,9 +162,9 @@ Voice commands start with the actual words you want to speak followed by a ':' c
162
162
163
163
You might have noticed that we've been using the key() and insert() actions in the example files so far. There are a number of built in actions, and extra actions can be defined in `.py` files. To get a complete list of defined actions you can do the following:
164
164
165
-
1. Right click on the Talon icon in your status bar, choose scripting, and then 'Console (REPL)'. This will open a terminal window where you type Python commands and the result of those commands are printed out.
165
+
1. Right click on the Talon icon in your status bar, choose scripting, and then 'Console (REPL)'. This will open a terminal window where you type Python commands and the results of those commands are printed out.
166
166
2. Type `actions.list()` and press enter. This will list out all the available actions.
167
-
3. You might like to look at this list of actions in your text editor (so you can search them, for example). To put the full list into your clipboard, copy and paste this code into the terminal window and press enter:
167
+
3. You might like to look at this list of actions in your text editor (so you can search them, for example). To put the full list into your clipboard, copy and paste this code into the talon console and press enter:
168
168
169
169
```python
170
170
import io;old=sys.stdout;sys.stdout = io.StringIO();actions.list();clip.set_text(sys.stdout.getvalue());sys.stdout = old
@@ -185,7 +185,7 @@ If you've read the above you should have some idea of how to make customizations
185
185
186
186
### Add new keyboard shortcuts
187
187
188
-
Often you will want to add a new voice command to press an applicationspecific keyboard shortcut. Let's choose the YouTube webpage as our example. The following `.talon` file defines two new voice commands:
188
+
Often you will want to add a new voice command to press an application-specific keyboard shortcut. Let's choose the YouTube webpage as our example. The following `.talon` file defines two new voice commands:
189
189
190
190
```talon
191
191
title: /YouTube/
@@ -220,7 +220,7 @@ Note the use of app.exe as the context matcher to match the filename of the acti
220
220
221
221
settings() blocks can be put in any `.talon` file and are used to change the value of settings given a matching context header. You can have multiple settings by putting each on its own indented line underneath the "settings():" line. You can include voice commands in the same file as a settings block.
222
222
223
-
You can paste the following code into the REPL to see a full list of available settings: `settings.list()`. A list of some of the more useful ones are[included here](../Customization/talon-files.md#tags-settings-and-other-capabilities). [Talon Community](https://github.com/talonhub/community) also has a list of some extra settings it defines in the `settings.talon` file.
223
+
You can paste the following code into the REPL to see a full list of available settings: `settings.list()`. A list of some of the more useful ones is[included here](../Customization/talon-files.md#tags-settings-and-other-capabilities). [Talon Community](https://github.com/talonhub/community) also has a list of some extra settings it defines in the `settings.talon` file.
224
224
225
225
### Keyboard shortcuts
226
226
@@ -234,21 +234,21 @@ The shortcut is global since there's no context matcher in this `.talon` file re
234
234
235
235
One thing that may not be immediately obvious is that re-using voice commands is perfectly acceptable. You can just create a new `.talon` file with a new context header and redefine the command.
236
236
237
-
This also provides a simple way of overriding the behaviour of existing voice commands from the [Talon Community](https://github.com/talonhub/community) user file set. Lets say you wanted to change the behaviour of the `touch` command so that it didn't hide the mouse grid if it was open.
237
+
This also provides a simple way of overriding the behaviour of existing voice commands from the [Talon Community](https://github.com/talonhub/community) user file set. Let's say you wanted to change the behaviour of the `touch` command so that it didn't hide the mouse grid if it was open.
238
238
239
239
The existing code is in a `.talon` file without a context header called `mouse.talon`:
240
240
241
241
```talon
242
242
touch:
243
243
mouse_click(0)
244
-
# close the mouse grid if open
244
+
# Close the mouse grid if open
245
245
user.grid_close()
246
246
# End any open drags
247
247
# Touch automatically ends left drags so this is for right drags specifically
248
248
user.mouse_drag_end()
249
249
```
250
250
251
-
We can see the `user.grid_close()` action is called to close the grid after clicking the mouse. Also note the lines starting with '#' characters are called comments. They are just there for documentation and will not be otherwise processed by Talon.
251
+
We can see the `user.grid_close()` action is called to close the grid after clicking the mouse. Also, note the lines starting with '#' characters are called comments. They are just there for documentation and will not be otherwise processed by Talon.
252
252
253
253
If we wanted to stop the `user.grid_close()` behaviour we could just create a new `.talon` file and put in the following contents:
254
254
@@ -262,8 +262,8 @@ touch:
262
262
user.mouse_drag_end()
263
263
```
264
264
265
-
Notice that we've given it a context header. Because this context headar is more specific (i.e. it has more rules in it) this implementation of "touch" will take precedence over the original. The implementation just has the `user.grid_close()` line and associated comment removed.
265
+
Notice that we've given it a context header. Because this context header is more specific (i.e. it has more rules in it) this implementation of "touch" will take precedence over the original. The implementation just has the `user.grid_close()` line and associated comment removed.
266
266
267
-
In general you can use this technique by just making a version of the `.talon` file you want to override and putting in more redundant rules to make it the more specific version. In addition to "os: " some other redundant filters you can add are "mode: command" (assuming you want to define the command in the default 'command' mode) and "speech.engine: wav2letter" (assuming you're not using Dragon).
267
+
In general, you can use this technique by just making a version of the `.talon` file you want to override and putting in more redundant rules to make it the more specific version. In addition to "os: " some other redundant filters you can add are "mode: command" (assuming you want to define the command in the default 'command' mode) and "speech.engine: wav2letter" (assuming you're not using Dragon).
268
268
269
269
This is a simple way of overriding voice commands using `.talon` files. Many other parts of the system (such as the behaviour of actions) can also be overridden, but this requires editing `.py` files.
0 commit comments