Skip to content

Commit

Permalink
Add support for Firefox Nightly (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
meuxx committed Jun 12, 2024
1 parent eaf9a80 commit 2f715ef
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pkg/assume/assume.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions pkg/browser/browsers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
FirefoxStdoutKey string = "FIREFOX_STDOUT"
ArcKey string = "ARC"
FirefoxDevEditionKey string = "FIREFOX_DEV"
FirefoxNightlyKey string = "FIREFOX_NIGHTLY"
CommonFateKey string = "COMMON_FATE"
)

Expand All @@ -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`}
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 8 additions & 2 deletions pkg/browser/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -159,6 +163,8 @@ func DetectInstallation(browserKey string) (string, bool) {
bPath, _ = ArcPathDefaults()
case FirefoxDevEditionKey:
bPath, _ = FirefoxDevPathDefaults()
case FirefoxNightlyKey:
bPath, _ = FirefoxNightlyPathDefaults()
default:
return "", false
}
Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions pkg/launcher/firefox_nightly.go
Original file line number Diff line number Diff line change
@@ -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 }

0 comments on commit 2f715ef

Please sign in to comment.