diff --git a/pkg/assume/assume.go b/pkg/assume/assume.go index 64ffa0eb..48ad33af 100644 --- a/pkg/assume/assume.go +++ b/pkg/assume/assume.go @@ -344,7 +344,7 @@ func AssumeCommand(c *cli.Context) error { return err } - if cfg.DefaultBrowser == browser.FirefoxKey || cfg.DefaultBrowser == browser.WaterfoxKey || cfg.DefaultBrowser == browser.FirefoxStdoutKey || cfg.DefaultBrowser == browser.FirefoxDevEditionKey || cfg.DefaultBrowser == browser.FirefoxNightlyKey { + if cfg.DefaultBrowser == browser.FirefoxKey || cfg.DefaultBrowser == browser.WaterfoxKey || cfg.DefaultBrowser == browser.FirefoxStdoutKey || cfg.DefaultBrowser == browser.FirefoxDevEditionKey || cfg.DefaultBrowser == browser.FirefoxNightlyKey || cfg.DefaultBrowser == browser.ZenKey { // transform the URL into the Firefox Tab Container format. consoleURL = fmt.Sprintf("ext+granted-containers:name=%s&url=%s&color=%s&icon=%s", containerProfile, url.QueryEscape(consoleURL), profile.CustomGrantedProperty("color"), profile.CustomGrantedProperty("icon")) } @@ -376,6 +376,10 @@ func AssumeCommand(c *cli.Context) error { l = launcher.Safari{} case browser.ArcKey: l = launcher.Arc{} + case browser.ZenKey: + l = launcher.Zen{ + ExecutablePath: browserPath, + } case browser.FirefoxDevEditionKey: l = launcher.FirefoxDevEdition{ ExecutablePath: browserPath, diff --git a/pkg/browser/browsers.go b/pkg/browser/browsers.go index 60765162..b1a49550 100644 --- a/pkg/browser/browsers.go +++ b/pkg/browser/browsers.go @@ -18,6 +18,7 @@ const ( StdoutKey string = "STDOUT" FirefoxStdoutKey string = "FIREFOX_STDOUT" ArcKey string = "ARC" + ZenKey string = "ZEN" FirefoxDevEditionKey string = "FIREFOX_DEV" FirefoxNightlyKey string = "FIREFOX_NIGHTLY" CustomKey string = "CUSTOM" @@ -65,6 +66,10 @@ var SafariPathMac = []string{"/Applications/Safari.app/Contents/MacOS/Safari"} var ArcPathMac = []string{"/Applications/Arc.app/Contents/MacOS/Arc"} +var ZenPathMac = []string{"/Applications/Zen Browser.app/Contents/MacOS/zen"} +var ZenPathLinux = []string{`/usr/bin/zen-browser`, `/opt/zen-browser/zen`} +var ZenPathWindows = []string{`\Program Files\Zen Browser\zen.exe`} + func ChromePathDefaults() ([]string, error) { // check linuxpath for binary install path, err := exec.LookPath("google-chrome-stable") @@ -250,3 +255,20 @@ func ArcPathDefaults() ([]string, error) { return nil, errors.New("os not supported") } } + +func ZenPathDefaults() ([]string, error) { + path, err := exec.LookPath("zen-browser") + if err == nil { + return []string{path}, nil + } + switch runtime.GOOS { + case "windows": + return ZenPathWindows, nil + case "darwin": + return ZenPathMac, nil + case "linux": + return ZenPathLinux, nil + default: + return nil, errors.New("os not supported") + } +} diff --git a/pkg/browser/detect.go b/pkg/browser/detect.go index a95d2c36..28bfeda0 100644 --- a/pkg/browser/detect.go +++ b/pkg/browser/detect.go @@ -50,7 +50,7 @@ func HandleManualBrowserSelection() (string, error) { withStdio := survey.WithStdio(os.Stdin, os.Stderr, os.Stderr) in := survey.Select{ Message: "Select one of the browsers from the list", - Options: []string{"Chrome", "Brave", "Edge", "Vivaldi", "Firefox", "Waterfox", "Chromium", "Safari", "Stdout", "FirefoxStdout", "Firefox Developer Edition", "Firefox Nightly", "Arc", "Custom"}, + Options: []string{"Chrome", "Brave", "Edge", "Vivaldi", "Firefox", "Waterfox", "Chromium", "Safari", "Stdout", "FirefoxStdout", "Firefox Developer Edition", "Firefox Nightly", "Arc", "Zen", "Custom"}, } var selection string clio.NewLine() @@ -139,6 +139,9 @@ func GetBrowserKey(b string) string { if strings.Contains(strings.ToLower(b), "arc") { return ArcKey } + if strings.Contains(strings.ToLower(b), "zen") { + return ZenKey + } if strings.Contains(strings.ToLower(b), "custom") { return CustomKey } @@ -169,6 +172,8 @@ func DetectInstallation(browserKey string) (string, bool) { bPath, _ = SafariPathDefaults() case ArcKey: bPath, _ = ArcPathDefaults() + case ZenKey: + bPath, _ = ZenPathDefaults() case FirefoxDevEditionKey: bPath, _ = FirefoxDevPathDefaults() case FirefoxNightlyKey: @@ -261,7 +266,7 @@ func ConfigureBrowserSelection(browserName string, path string) error { browserPath = customBrowserPath } - if browserKey == FirefoxKey || browserKey == WaterfoxKey || browserKey == FirefoxDevEditionKey || browserKey == FirefoxNightlyKey { + if browserKey == FirefoxKey || browserKey == WaterfoxKey || browserKey == FirefoxDevEditionKey || browserKey == FirefoxNightlyKey || browserKey == ZenKey { err := RunFirefoxExtensionPrompts(browserPath, browserName) if err != nil { return err diff --git a/pkg/granted/console.go b/pkg/granted/console.go index b6ab3494..38b3c6f2 100644 --- a/pkg/granted/console.go +++ b/pkg/granted/console.go @@ -54,7 +54,7 @@ var ConsoleCommand = cli.Command{ if err != nil { return err } - if c.Bool("firefox") || cfg.DefaultBrowser == browser.FirefoxKey || cfg.DefaultBrowser == browser.FirefoxStdoutKey { + if c.Bool("firefox") || cfg.DefaultBrowser == browser.FirefoxKey || cfg.DefaultBrowser == browser.FirefoxStdoutKey || cfg.DefaultBrowser == browser.ZenKey { // transform the URL into the Firefox Tab Container format. consoleURL = fmt.Sprintf("ext+granted-containers:name=%s&url=%s&color=%s&icon=%s", c.String("container-name"), url.QueryEscape(consoleURL), c.String("color"), c.String("icon")) } @@ -97,6 +97,10 @@ var ConsoleCommand = cli.Command{ l = launcher.Firefox{ ExecutablePath: cfg.CustomBrowserPath, } + case browser.ZenKey: + l = launcher.Zen{ + ExecutablePath: cfg.CustomBrowserPath, + } case browser.SafariKey: l = launcher.Safari{} case browser.CustomKey: diff --git a/pkg/launcher/zen.go b/pkg/launcher/zen.go new file mode 100644 index 00000000..c0d9d135 --- /dev/null +++ b/pkg/launcher/zen.go @@ -0,0 +1,15 @@ +package launcher + +type Zen struct { + ExecutablePath string +} + +func (l Zen) LaunchCommand(url string, profile string) ([]string, error) { + return []string{ + l.ExecutablePath, + "--new-tab", + url, + }, nil +} + +func (l Zen) UseForkProcess() bool { return true }