Skip to content

file_manager

The community/tags/file_manager directory contains the core logic for a file manager tag in Talon. It provides a way to navigate, select, and manipulate files and directories using voice commands. This functionality is implemented in the file_manager.talon and file_manager.py files.

  • file_manager.talon defines the voice commands and their corresponding actions. These commands allow the user to:

    • Navigate directories using commands like "go parent", and "follow" with a directory name or number.
    • Select directories and files by name or number.
    • Open files and directories using their name or number.
    • Create new folders using "folder new" followed by a name.
    • Show properties of files or folders using "properties show".
    • Open a terminal in the current location with "terminal here".
    • Navigate through pages of directories and files using "folder next/last" and "file next/last".
    • Refresh the file list using "manager refresh".
    • Show or hide file and directory pickers using "manager show" and "manager close".

    The file utilizes the user.file_manager_directories and user.file_manager_files lists to populate the available options for navigation and selection which are defined in file_manager.py.

  • file_manager.py contains the core Python implementation of the file manager logic. It defines actions, captures, settings, lists, and the UI that makes the voice commands function.

    • It defines the user.file_manager tag which is used by the file_manager.talon file to enable its commands. It also defines the lists user.file_manager_directories and user.file_manager_files to hold the current available directories and files, which are populated using the get_directory_map and get_file_map functions.
    • The Actions class defines all of the actions used by the talon file, including the file_manager_open_directory, file_manager_select_file, file_manager_new_folder, etc. These actions are implemented using the Pathlib module to interact with the filesystem.
    • The gui_folders and gui_files functions are used to render an imgui window displaying the current list of directories and files. These windows are shown or hidden by the file_manager_toggle_pickers action. They also provide a way to navigate through pages of directories and files when the limit set by file_manager_imgui_limit has been reached.
    • The update_lists function updates the user.file_manager_directories and user.file_manager_files lists based on the current path. It uses get_directory_map and get_file_map to retrieve a list of directories and files which are used in the gui_files and gui_folders functions for display.
    • The file sets up event handlers that use actions.user.file_manager_current_path() to determine the current path of the file manager and update the available files and directories. When the current path changes, the lists are updated and the imgui windows are refreshed.

The file_manager.talon file defines the voice interface and delegates the actual logic of interacting with the file system to file_manager.py. Together, these files provide the foundation for a voice-controlled file management system in Talon.