cmd/internal/browser: Open() shouldn’t rely on Commands() #33148
Labels
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Commands()
is used as the only backend forOpen()
, but there’s OS-specific ways to open things in a browser instead. Sadly on Linux, it is complex:$BROWSER
for a “:”-delimited list of executables.xdg-settings get default-web-browser
will return the .desktop file name, e.g.firefox.desktop
${XDG_DATA_HOME-$HOME/.local/share}:${XDG_DATA_DIRS-/usr/local/share/:/usr/share/}
(subdirectoryapplications
)Exec
line in that file and replace%s
,%u
and whatever with the file name/url/… to get a command linexdg-open
As said, this is harder than it should be, but it’s the only way to do it correctly AFAIK.
xdg-open
does all this, but there’s no way to tell it “open the path/URL I give you with a browser”. If you e.g. want to open a SVG with a browser, you need to go the above route.The text was updated successfully, but these errors were encountered: