Skip to content

command_search

The command_search directory provides a standardized interface and voice command structure for searching and executing arbitrary commands within applications (often utilizing an application's native command palette or search menu).

It accomplishes this by defining a reusable Talon tag and an abstract action that other application-specific configurations can implement.

How It Works

This directory acts as an API definition for command searching. By defining a tag (user.command_search) and a corresponding action (user.command_search), it decouples the voice command activation from the specific application-level implementation.

When a user speaks the defined voice command, Talon routes the text to the action. Because the action's behavior is defined abstractly, different applications can implement their own search routines (e.g., opening a VS Code command palette, triggering a spotlight search, or opening an application menu) while the user maintains a single, consistent voice interface.

File Breakdown

command_search.py

This file sets up the Python declaration for the command search capability.

  • Tag Declaration: It registers the command_search tag with the Talon system. This tag can be enabled by other context files when an active application supports command searching.
  • Action Declaration: It defines the command_search(command: str = "") action inside the command_search_actions class. This action acts as a placeholder interface. Other scripts in the repository override this action to implement the actual keystrokes or API calls required to perform a search in a given application.

command_search.talon

This file defines the actual voice command associated with the tag.

  • Tag Requirement: The file is only active when the user.command_search tag is enabled in the current context.
  • Voice Command: It defines the command: talon ^please [<user.text>]$: user.command_search(user.text or "") This allows a user to say "please" followed by an optional search term (e.g., "please format document" or just "please"). Speaking this command invokes the user.command_search action, passing any dictated text to the application-specific implementation.