Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to x-www-browser over xdg-open for handling menu actions #1214

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions ee/desktop/user/menu/action_open_url_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
package menu

import (
"fmt"
"os/exec"
)

// open opens the specified URL in the default browser of the user
// See https://stackoverflow.com/a/39324149/1705598
var browserLaunchers = []string{"xdg-open", "x-www-browser"}

func open(url string) error {
return exec.Command("xdg-open", url).Start()
errList := make([]error, 0)
for _, browserLauncher := range browserLaunchers {
cmd := exec.Command(browserLauncher, url)
if err := cmd.Start(); err != nil {
errList = append(errList, fmt.Errorf("could not open browser with %s: %w", browserLauncher, err))
continue
}

// Successfully opened URL, nothing else to do here
return nil
}
return fmt.Errorf("could not successfully open browser with any given launchers: %+v", errList)
}