Skip to content

browser

The community/tags/browser directory contains files that implement browser-specific functionality for Talon. It provides a common interface for controlling browsers across different platforms.

The core functionality is in browser.py, which defines actions for controlling browser tabs and navigation. It also contains functions for determining the current address, which it does by parsing the window title. Some key actions include:

  • address(): Extracts the URL from the window title. This is used to copy the address, duplicate tabs, and other address-based actions.
  • focus_address(): Focuses the browser's address bar.
  • go(url): Navigates to a given URL.
  • go_back() / go_forward(): Navigates back or forward in browsing history.
  • tab_jump(number) / tab_final(): Jumps to a specific tab.
  • focus_page(): Sets focus back to the web page content, removing focus from the address bar or other UI elements.

The file browser.talon defines Talon commands that trigger the actions in browser.py. For example, the command "go home" will call the browser.go_home() action, which presses alt-home. It also tags the context with user.address, user.find, and user.navigation, which enables additional commands defined elsewhere (not in this directory).

The browser_mac.py file contains actions that are specific to macOS. For example, the address detection is different; it uses the Accessibility API if possible, otherwise it falls back to using AppleScript. It also defines some of the same browser actions as browser.py but using the macOS command key. If browser_mac.py and browser.py define the same actions, then browser_mac.py will override browser.py on macOS.