Adding Browsers

Adding Browsers

This document explains how to add support for new browsers to the gosuki project, focusing on Chromium-based and Firefox-based browsers. It covers locating browser data directories, modifying code for package-specific paths, and verifying functionality.

This will require build dependencies and minimal knowledge of building the GoSuki from the source code.


Available Browser Families

The following browser families are currently supported:

FamilyExample BrowsersNotes
ChromeBasedChrome, Chromium, BraveUses ChromeBrowser definition
MozillaFirefox (-esr), LibrewolfUses MozBrowser definition
QutebrowserQutebrowserUses manual definition

These families are defined in pkg/browsers/base.go and configured in the unified YAML file (browsers.yaml), replacing the previous platform-specific files.


Adding a New Browser (YAML-Based Method)

Step 1: Edit browsers.yaml

GoSuki now uses a unified YAML configuration file to define browser paths. This file is generated into Go code automatically.

  1. Locate browsers.yaml in the project:
    pkg/browsers/browsers.yaml

  2. Add your browser configuration in the appropriate section:

Example 1: Adding a Chrome-based browser (Vivaldi)

chrome:
  vivaldi:
    linux:
      base_dir: ~/.config/vivaldi
      snap: ~/snap/vivaldi/current/.config/vivaldi
      flat: ~/.var/app/com.vivaldi.Vivaldi/config/vivaldi
    darwin:
      base_dir: ~/Library/Application Support/Vivaldi

Example 2: Adding a Firefox-based browser (Waterfox)

mozilla:
  waterfox:
    linux:
      base_dir: ~/.waterfox
      flat: ~/.var/app/net.waterfox.waterfox/.waterfox
    darwin:
      base_dir: ~/Library/Application Support/Waterfox

Example 3: Adding a custom browser (like an unknown browser family)

other:
  # New family value (must match an existing BrowserFamily constant)
  mybrowser:
    myflavour:
      linux:
        base_dir: ~/.mybrowser
        snap: /nonexistent
        flat: /nonexistent
      darwin:
        base_dir: ~/Library/Application Support/MyBrowser

Step 2: Regenerate the Code

After editing browsers.yaml, run:

go generate ./pkg/browsers

This will:

  1. Generate platform-specific Go code for all platforms in the project (e.g., defined_browsers_linux.go, defined_browsers_darwin.go)
  2. Remove outdated generated files (as specified in the new .gitignore)

Step 3: Test Your New Browser

  1. Start the daemon to test your new browser integration:

    go run ./cmd/gosuki --tui start
  2. Open your browser and add a bookmark, then verify:

    go run ./cmd/gosuki detect
  3. Check for your new browser in the output:

Expected Output
   vivaldi      /home/spike/.config/vivaldi
   waterfox     /home/spike/.waterfox

Manual Browser Definition (For Special Cases)

If you need to add functionality beyond the standard YAML configuration:

  1. Use the browsers.BrowserDef struct directly in Go code
  2. Add your custom implementation to a separate file in pkg/browsers/
  3. Register it with AddBrowserDef()
Example
// CustomBrowser.go

package browsers

// Define a special browser with custom functionality
var MySpecialBrowser = BrowserDef{
    Flavour: "mybrowser",
    Family:  Qutebrowser,
    BaseDir: "~/.mybrowser",
    SnapDir: "/nonexistent",
    FlatpakDir: "/nonexistent",
}

// Register the new browser
func init() {
    AddBrowserDef(MySpecialBrowser)
}

Tip

Use the manual method only when:

  • You need custom detection logic not supported by the YAML format
  • Your browser has non-standard path formats
  • You’re adding a new browser family (not covered by existing BrowserFamily constants)