file_manager
This directory implements generic file management capabilities for Talon. It enables hands-free navigation, selection, and manipulation of files and folders in supported file managers (both GUI and command-line interfaces) by dynamic indexing, generating voice-spoken forms of directory contents, and displaying quick-selection overlays.
The implementation relies on three primary files that coordinate state tracking, user interface overlays, and voice trigger mappings:
- file_manager.py: The Python backend that manages settings, reads the file system, generates spoken forms of files/directories, manages the GUI overlay, and synchronizes lists based on active window events.
- file_manager.talon: The core file containing platform-independent voice commands for navigating folders, selecting files, and opening terminals.
- file_manager_win.talon: A platform-specific extension for Windows that adds volume/drive switching commands (e.g., changing to the
C:orD:drive).
Core Mechanism
The framework operates by tracking the state of the active window. The integration works through the following sequence of operations:
- Window Event Tracking: file_manager.py registers event listeners on
win_titleandwin_focus. When a window receives focus or changes its title, the script checks if the active application context has theuser.file_managertag. - Context-Aware Path Extraction: If the tag is present, the script invokes the action
user.file_manager_current_path(). Specific application contexts (implemented elsewhere in the repository) override this action to return the absolute path of the directory currently being viewed. - Dynamic Spoken List Generation: Once the current path is retrieved, file_manager.py reads the directory contents (up to limits configured via settings). It filters out non-descriptive names using a list of excluded words and passes the remaining file/folder names to
actions.user.create_spoken_forms_from_list(). This translates complex system names into pronounceable phrases and updates:user.file_manager_directoriesuser.file_manager_files
- Indexed Selection Overlays: The files and directories are sorted and displayed in two side-by-side
imguipanels (using Talon's built-in GUI engine) if they are enabled via theuser.file_manager_auto_show_pickerssetting or explicitly toggled by voice. This allows users to target files and directories by simple indexed numbers (e.g., "open numb three").
Command Reference & Interaction
The voice commands defined in file_manager.talon hook into the dynamic spoken lists and index arrays.
- Navigation: Commands like
go parentordaddyascend the folder hierarchy. Users can sayfollow <directory_name>using the spoken form generated by the script, or use index numbers shown on the GUI overlay withfollow numb <number>. - File Selection: You can highlight files or folders without opening them via
select folder <name>orselect file numb <number>. - Execution & Manipulation: Saying
open <file_name>triggers the application's default open behavior. You can also run system commands such asfolder new <name>to create a subdirectory,properties showto inspect metadata, orterminal hereto spin up a shell in the directory's current path. - Pagination: For large directories, users can paginate through the generated list overlays by saying
folder next,folder last,file next, orfile last.
On Windows environments, the command list is augmented by file_manager_win.talon to allow drive-swapping (e.g. saying go cap to transition to C:).