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:
| Family | Example Browsers | Notes |
|---|---|---|
ChromeBased | Chrome, Chromium, Brave | Uses ChromeBrowser definition |
Mozilla | Firefox (-esr), Librewolf | Uses MozBrowser definition |
Qutebrowser | Qutebrowser | Uses 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.
Locate
browsers.yamlin the project:pkg/browsers/browsers.yamlAdd 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/VivaldiExample 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/WaterfoxExample 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/MyBrowserStep 2: Regenerate the Code
After editing browsers.yaml, run:
go generate ./pkg/browsersThis will:
- Generate platform-specific Go code for all platforms in the project (e.g.,
defined_browsers_linux.go,defined_browsers_darwin.go) - Remove outdated generated files (as specified in the new
.gitignore)
Step 3: Test Your New Browser
Start the daemon to test your new browser integration:
go run ./cmd/gosuki --tui startOpen your browser and add a bookmark, then verify:
go run ./cmd/gosuki detectCheck for your new browser in the output:
Expected Output
vivaldi /home/spike/.config/vivaldi
waterfox /home/spike/.waterfoxManual Browser Definition (For Special Cases)
If you need to add functionality beyond the standard YAML configuration:
- Use the
browsers.BrowserDefstruct directly in Go code - Add your custom implementation to a separate file in
pkg/browsers/ - 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
BrowserFamilyconstants)