diff --git a/pkg/assume/assume.go b/pkg/assume/assume.go index aef9df64..a88eac6f 100644 --- a/pkg/assume/assume.go +++ b/pkg/assume/assume.go @@ -464,7 +464,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 { + if cfg.DefaultBrowser == browser.FirefoxKey || cfg.DefaultBrowser == browser.WaterfoxKey || cfg.DefaultBrowser == browser.FirefoxStdoutKey || cfg.DefaultBrowser == browser.FirefoxDevEditionKey || cfg.DefaultBrowser == browser.FirefoxNightlyKey { // 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")) } @@ -500,6 +500,10 @@ func AssumeCommand(c *cli.Context) error { l = launcher.FirefoxDevEdition{ ExecutablePath: browserPath, } + case browser.FirefoxNightlyKey: + l = launcher.FirefoxNightly{ + ExecutablePath: browserPath, + } case browser.CommonFateKey: l = launcher.CommonFate{ // for CommonFate, executable path must be set as custom browser path diff --git a/pkg/browser/browsers.go b/pkg/browser/browsers.go index 3817afe1..8e832d03 100644 --- a/pkg/browser/browsers.go +++ b/pkg/browser/browsers.go @@ -19,6 +19,7 @@ const ( FirefoxStdoutKey string = "FIREFOX_STDOUT" ArcKey string = "ARC" FirefoxDevEditionKey string = "FIREFOX_DEV" + FirefoxNightlyKey string = "FIREFOX_NIGHTLY" CommonFateKey string = "COMMON_FATE" ) @@ -43,6 +44,10 @@ var FirefoxDevPathMac = []string{"/Applications/Firefox Developer Edition.app/Co var FirefoxDevPathLinux = []string{`/usr/bin/firefox-developer`, `/../../mnt/c/Program Files/Firefox Developer Edition/firefox.exe`} var FirefoxDevPathWindows = []string{`\Program Files\Firefox Developer Edition\firefox.exe`} +var FirefoxNightlyPathMac = []string{"/Applications/Firefox Nightly.app/Contents/MacOS/firefox"} +var FirefoxNightlyPathLinux = []string{`/usr/bin/firefox-nightly`, `/../../mnt/c/Program Files/Firefox Nightly/firefox.exe`} +var FirefoxNightlyPathWindows = []string{`\Program Files\Firefox Nightly\firefox.exe`} + var WaterfoxPathMac = []string{"/Applications/Waterfox.app/Contents/MacOS/waterfox"} var WaterfoxPathLinux = []string{`/usr/bin/waterfox`, `/../../mnt/c/Program Files/Waterfox/waterfox.exe`} var WaterfoxPathWindows = []string{`\Program Files\Waterfox\waterfox.exe`} @@ -151,6 +156,24 @@ func FirefoxDevPathDefaults() ([]string, error) { } } +func FirefoxNightlyPathDefaults() ([]string, error) { + // check linuxpath for binary install + path, err := exec.LookPath("firefox-nightly") + if err == nil { + return []string{path}, nil + } + switch runtime.GOOS { + case "windows": + return FirefoxNightlyPathWindows, nil + case "darwin": + return FirefoxNightlyPathMac, nil + case "linux": + return FirefoxNightlyPathLinux, nil + default: + return nil, errors.New("os not supported") + } +} + func WaterfoxPathDefaults() ([]string, error) { // check linuxpath for binary install path, err := exec.LookPath("waterfox") diff --git a/pkg/browser/detect.go b/pkg/browser/detect.go index 26b1e534..a779da51 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", "Firefox", "Waterfox", "Chromium", "Safari", "Stdout", "FirefoxStdout", "Firefox Developer Edition", "Arc"}, + Options: []string{"Chrome", "Brave", "Edge", "Firefox", "Waterfox", "Chromium", "Safari", "Stdout", "FirefoxStdout", "Firefox Developer Edition", "Firefox Nightly", "Arc"}, } var selection string clio.NewLine() @@ -108,6 +108,10 @@ func GetBrowserKey(b string) string { return FirefoxDevEditionKey } + if strings.ToLower(b) == "firefox nightly" { + return FirefoxNightlyKey + } + if strings.Contains(strings.ToLower(b), "brave") { return BraveKey } @@ -159,6 +163,8 @@ func DetectInstallation(browserKey string) (string, bool) { bPath, _ = ArcPathDefaults() case FirefoxDevEditionKey: bPath, _ = FirefoxDevPathDefaults() + case FirefoxNightlyKey: + bPath, _ = FirefoxNightlyPathDefaults() default: return "", false } @@ -241,7 +247,7 @@ func ConfigureBrowserSelection(browserName string, path string) error { browserPath = customBrowserPath } - if browserKey == FirefoxKey || browserKey == WaterfoxKey || browserKey == FirefoxDevEditionKey { + if browserKey == FirefoxKey || browserKey == WaterfoxKey || browserKey == FirefoxDevEditionKey || browserKey == FirefoxNightlyKey { err := RunFirefoxExtensionPrompts(browserPath, browserName) if err != nil { return err diff --git a/pkg/launcher/firefox_nightly.go b/pkg/launcher/firefox_nightly.go new file mode 100644 index 00000000..eac9ed0a --- /dev/null +++ b/pkg/launcher/firefox_nightly.go @@ -0,0 +1,15 @@ +package launcher + +type FirefoxNightly struct { + ExecutablePath string +} + +func (l FirefoxNightly) LaunchCommand(url string, profile string) []string { + return []string{ + l.ExecutablePath, + "--new-tab", + url, + } +} + +func (l FirefoxNightly) UseForkProcess() bool { return true }